When you get a warning like "supplied argument is not a valid MySQL result resource", the problem is due to one or more these:
Failed to connect to database server.
Failed to select correct database.
Failed to execute SQL statement.
Since you are sure of the first two, the problem must be with the third.
One possible problem is that $counter is not defined, so your SQL statement becomes:
SELECT * FROM quiz ORDER BY id ,1
and that should result in a failed execution of the SQL statement.
Another possible problem is that the problem actually lies in this SQL statement:
$query = @mysql_query("SELECT * FROM `question` WHERE `q` = '$questionNum'");
But since you suppress errors from that, you do not detect anything. (Though actually, I suspect that a failed SQL statement execution here should not affect $display, but I personally would finish up a SELECT statement before executing another SQL statement.)
To get a better idea what is wrong, change this:
$display = mysql_query("SELECT * FROM quiz ORDER BY id $limit_value");
$query = @mysql_query("SELECT * FROM `question` WHERE `q` = '$questionNum'");
To this:
$display = mysql_query("SELECT * FROM quiz ORDER BY id $limit_value")
OR die(mysql_error());
Additionally, you need to set error_reporting to E_ALL (or to E_ALL | E_STRICT).