[PHP] PHP Mysql Error Code 1062 - Duplicates found

2003-06-24 Thread Ow Mun Heng
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 brbr.mysql_affected_rows(). Drives  DCM combo inserted into
database.;
else
echo \nbrbrDuplicate 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



Re: [PHP] PHP Mysql Error Code 1062 - Duplicates found

2003-06-24 Thread Jeff Harris
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 brbr.mysql_affected_rows(). Drives  DCM combo inserted into
|database.;
|else
|echo \nbrbrDuplicate 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-generalm=105606491624771w=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.



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