Whenever I visit the page I get: 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 '' at line 1
It has to do with the second while loop
<html>
<body>
<?php
mysql_connect("mysql.1freehosting.com", "u533288591_sdc", "mypass") or die(mysql_error());
mysql_select_db("u533288591_sdc");
$name = $_POST['name'];
$probably_needed = "questions";
$grade = $_POST['class'] ;
$answers ="answers" ;
$query = mysql_query("SELECT * FROM $probably_needed ") or die(mysql_error());
$otherquery = mysql_query("select * from $ANSWERS ") or die (mysql_error()) ;
while($row = mysql_fetch_array($query)){
echo "<a href=\"answer.php?name=" . $name . "&subject=" . $row['Subject'] . "&grade=" . $grade . "\">" . $row['Subject'] ."</a>" ;
while($answerrow = mysql_fetch_array($otherquery)){
if ($answerrow['name'] == $name){
if ($answerrow['subject'] == $row['Subject']){
echo "success" ;
}
}
}
}
?>
</body>
</html>