PDA

View Full Version : mySQL User Name query?


JamesAB
02-03-2006, 05:47 PM
What is the correct way to query a vBulletin database to see if a user name already exists? I just need to put together a simple php script that will return one value if the username is free or another if the user name already exists.

Thanks for your help,
James

filburt1
02-03-2006, 06:33 PM
SELECT userid FROM user WHERE username = "the username to check"
If it returns anything, then the user exists. Remember TABLE_PREFIX and escaping the username.

JamesAB
02-03-2006, 07:00 PM
Thanks for the quick response.

Does vBulletin use addslashes() before adding user names to the database? So I should use stripslashes()? Or is there another function to use?

Thanks,
James

filburt1
02-03-2006, 09:26 PM
Highly unlikely. The only escaping it usually does is for HTML (which IMHO it shouldn't do because it assumes a web front end other than something like XML or a custom application--both of which my site uses).