dladenhe
06-17-2008, 06:11 PM
Hey,
I am making a registration page with PHP and mySQL, and I'm having an error which I cannot solve. At this point, I am trying to check if the username already exists in the database. This is the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' WHERE 'username'='admin'' at line 1
Here is the code:
$sql = "SELECT * FROM 'users' WHERE 'username'='$username'";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
echo "this username already exists"; }
Does it have to do with my version of mySQL? I have version 5.0.24a
THANKS FOR YOUR HELP
I am making a registration page with PHP and mySQL, and I'm having an error which I cannot solve. At this point, I am trying to check if the username already exists in the database. This is the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' WHERE 'username'='admin'' at line 1
Here is the code:
$sql = "SELECT * FROM 'users' WHERE 'username'='$username'";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
echo "this username already exists"; }
Does it have to do with my version of mySQL? I have version 5.0.24a
THANKS FOR YOUR HELP