> Well, show us a part of your code. Do var_dump($value) before you > enter it into the database, and see if it still says 0x9f54. The error: string(2) "" Duplicate entry '' for key 1 -- .~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org / v \ Simplicity is Beauty! May the Force and Farce be with you! /( _ )\ (Ubuntu 6.10) Linux 2.6.20.6 ^ ^ 19:14:01 up 3 days 2:05 1 user load average: 2.24 1.42 1.14 news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk
<? class MYSQL { private $fhandle; var $row; function MYSQL($host,$db,$usr,$pwd) { $this->fhandle=new mysqli($host,$usr,$pwd,$db) or die(mysqli_error($this->fhandle)); $this->query("set names 'big5'"); } function query($sql_str) { $this->row=mysqli_query($this->fhandle, $sql_str) or die(mysqli_error($this->fhandle)); } function affected_rows() { return mysqli_affected_rows($this->row); } function num_rows() { return mysqli_num_rows($this->row); } function fetch_assoc() { return mysqli_fetch_assoc($this->row); } function __destruct() { mysqli_close($this->fhandle); } function begin_tran() { mysqli_autocommit($this->fhandle, FALSE); } function commit() { mysqli_commit($this->fhandle); mysqli_autocommit($this->fhandle, TRUE); } function rollback() { mysqli_rollback($this->fhandle); mysqli_autocommit($this->fhandle, TRUE); } } function showcode($cChar) { return "[".dechex(ord(substr($cChar,0,1))).".".dechex(ord(substr($cChar,1,1)))."]"; } $target=new MYSQL("localhost","testing","root","testing"); $fhandle=dbase_open("/home/bt/canton.DBF",0); if ($fhandle) { $reccount=dbase_numrecords($fhandle); echo "input count: ".$reccount."\n"; $target->query("show tables like 'canton';"); if ($target->num_rows()>0) $target->query("drop table canton"); $target->query( "create table canton (" . " big5 char(2) not null," . " thekey char(6)," . " canton char(10)," . " changjei char(10)," . " touched integer," . " primary key (big5)" . " ) character set big5;" ); for ($ii=1; $ii<=$reccount; $ii++) { $row=dbase_get_record_with_names($fhandle,$ii); $ss=$row['BIG5']; echo var_dump($ss); $target->query("select * from canton where big5='".$ss."'"); $yy = $target->num_rows(); if ($yy>0) { $query="update canton set touched=" . $row["TOUCHED"] . " where big5='" . $ss . "';"; } else { $query="insert into canton (" . " big5," . " thekey," . " changjei," . " canton," . " touched " . ") values (" . "'$ss'," . "'".$row["THEKEY"]."'," . "'".$row["CHANGJEI"]."'," . "'".$row["CANTON"]."'," . $row["TOUCHED"] . ");"; } $result=$target->query($query); if (! $target->row) echo showcode($ss); } $result=$target->query("select count(*) as cnt from canton"); $yy = $target->fetch_assoc(); echo "output count: ".$yy['cnt']."\n"; dbase_close($fhandle); } ?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php