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? 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. 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? 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
Archived
This topic is now archived and is closed to further replies.