Hi All,

        I found out how to do it already. Thanks for the help.

mysql_error() was the key..

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-----Original Message-----
From: Ow Mun Heng 
Sent: Wednesday, June 25, 2003 10:03 AM
To: [EMAIL PROTECTED]
Subject: PHP & Mysql Error Code 1062 - Duplicates found


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to