View Single Post
Old 01-03-2013, 02:57 PM   PM User | #6
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,855
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
Quote:
Originally Posted by tangoforce View Post
If you set the column to unique and try to insert an existing user, the sql server won't insert it. You can then test whether or not the user was inserted by using mysql_num_rows() which will tell you how many rows were inserted - of course if there were none due to the username already existing then it will be 0.
or you just test whether the query suceeded. mysql_query() returns false on any DB/query error (like such a constraint violation).
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote