Here's my code: $es_query = "SELECT `UserName` FROM `User` WHERE `UserType` = 1"; $try_query = mysql_query($es_query or die(mysql_error())); $esnames = mysql_fetch_array($try_query or die(mysql_error())); PHP: I get the following 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 '1' at line 1 This makes me cry.
You have to complete bracket after $es_query and before or die statement thats the problem otherwise it will consider or die as a query too
try this: $es_query = "SELECT `UserName` FROM `User` WHERE `UserType` = '1'"; $try_query = mysql_query($es_query) or die(mysql_error()); $esnames = mysql_fetch_array($try_query) or die(mysql_error()); and make sure that your table name and its field are as same as you are coding in your script.