pinacoladaxb Posted November 11, 2009 Share Posted November 11, 2009 I'm having some trouble with a query I'm trying to make. I can't figure out what's wrong here. Can anyone see the issue? sqltest.php source: <?php $q = 'test'; $con = mysql_connect('localhost', 'pauliuko', 'password') or die(mysql_error()); mysql_select_db('pauliuko_atomicriot', $con) or die(mysql_error()); $query = mysql_query("SELECT COUNT(*) FROM 'ac_users' WHERE 'username' = '$q'") or die(mysql_error()); list($number)=mysql_fetch_row($query); echo $number; mysql_close($con); ?> sqltest.php displays: 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 ''ac_users' WHERE 'username' = 'test'' at line 1 I double checked my database and there is a table named 'ac_users' with a column named 'username'. Quote Link to comment Share on other sites More sharing options...
haku Posted November 11, 2009 Share Posted November 11, 2009 You are using quotes (') and you need to use backticks (`). Quote Link to comment Share on other sites More sharing options...
MattR Posted November 11, 2009 Share Posted November 11, 2009 Yeah, try this: $query = mysql_query("SELECT COUNT(*) FROM `ac_users` WHERE `username` = '$q'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.