Re: PHP & Mysql Error Code 1062 - Duplicates found

From: Date: Wed, 25 Jun 2003 04:17:58 +0000
Subject: Re: PHP & Mysql Error Code 1062 - Duplicates found
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-152699@lists.php.net to get a copy of this message
On Jun 25, 2003, "Ow Mun Heng" claimed that: |Hi PHP'ers, | | I've got a question regarding the input of (multiple) data into |mysql through PHP. | |If there is already an entry in the database, then an mysql will generate an |error 1062 stating that the entry is a duplicate. (This will happen only if |I input the data through mySQL using xterm, if I use PHP, then I only get |the 'duplicate entry found', partly cause I don't know how to get the error |code as well as the duplicate entry returned to PHP to be output'ed to the |browser. | |Below is my code. $my_query is concatenated from an array. | |$my_query = $my_query. |"\n('".$SN[$i]."','".$DCM[$i]."','".$Supp[$i]."','".$time_now."'),"; |$query = "INSERT INTO pioneer(serial_no,dcm,supplier,fa_timestamp) VALUES |$my_query;"; |$result = mysql_db_query('tracker',$query); | |if ($result) |echo "<br><br>".mysql_affected_rows()." Drives & DCM combo inserted into |database."; |else |echo "\n<br><br>Duplicate entry found. Data not inserted."; | | |Can anyone help me out? | | |Cheers, |Mun Heng, Ow |H/M Engineering |Western Digital M'sia |DID : 03-7870 5168 | |-- http://marc.theaimsgroup.com/?l=php-general&m=105606491624771&w=2 -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855.

« previous php.general (#152699) next »