MDanz Posted January 6, 2011 Share Posted January 6, 2011 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 '-course WHERE GRADE BETWEEN 0 AND 9' at line 1 class Grade { public function results($grade) { $beginning = $grade-9; $query = mysql_query("SELECT * FROM student-course WHERE GRADE BETWEEN $beginning AND $grade") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { $sid = $row['SID']; $cid = $row['CID']; echo "<li>$sid-$cid</li>"; } } } ?> why am i getting this error? Quote Link to comment https://forums.phpfreaks.com/topic/223584-mysql-error-help-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 6, 2011 Share Posted January 6, 2011 You shouldn't use special characters in table names. The - is a special character. Only the set of alphanumeric characters from the current character set, “_”, and “$” are not special. Quote Link to comment https://forums.phpfreaks.com/topic/223584-mysql-error-help-you-have-an-error-in-your-sql-syntax/#findComment-1155726 Share on other sites More sharing options...
MDanz Posted January 6, 2011 Author Share Posted January 6, 2011 can't i put backticks around the table name or apostrophes? Quote Link to comment https://forums.phpfreaks.com/topic/223584-mysql-error-help-you-have-an-error-in-your-sql-syntax/#findComment-1155728 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.