Hi I’m new to PHP and MySQL and I’m trying to return a MySQL query using a PHP variable that has been passed to it. I currently get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\moodle\logicquiz\quiz.php on line 57
Error performing query: 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 ''venn'' at line 1
Where "venn is the table name"
The code works when I put a table name in instead of $quiz_name, so I'm guessing there is a problem with my syntax as the error message suggests, any suggestions as to what I'm doing wrong would be gratefully appreciated.
Many Thanks
NH
//gets quiz name from URL passed in code in previous page
$quiz_name = $_GET['quiz'];
//counts number of questions in a quiz table
$result = mysql_query("SELECT * FROM '$quiz_name'");
$num_rows = mysql_num_rows($result12);
if (!$result) {
exit ('<p> Error performing query: ' .
mysql_error() . '<p/>');
}