Here is a simple solution.

if (!($SQLresult = @mysql_query($SQLquery, $DBresource)))
{
        echo "Errormessage...";

} //endif


Of course you could also check the Errortype [mysql_errno()]
to be sure, whether it is a duplicate-key-errror.

The cleanest solution is to use an ID-key, such as:

ID, Username, Name, Adress, ..., Somefield

Then, of course you have to check on existing users.

You have to be careful to handle two equal requests 
posted at the same time! 
Martin Towell's code might fail when the same insert-
request is executed just after he has queried the count(*)
and before PHP is inserting.

Then PHP thinks, the user doesn't exist [count(*)== 0] and 
the insert fails because of duplicate keys.

-> always check the mysql_error


Regards,



Christian Leberfinger

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

Reply via email to