09-20-2007, 12:20 PM
|
#7 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
OK, the better way to achieve this is to frist execute the INSERT query which will fail on duplicates (assuming of course, you have approprirate PK/unique fields). You then simply determine if the last INSERT actually inserted any data (using mysql_affected_rows), finally, if no data was inserted, you can simply UPDATE the user record. The code should look like this:
PHP Code:
Execute INSERT query
if (mysql_affected_rows() == -1) { Execute UPDATE query }
|
|
|
|