the follwing is a submit script for multiple question forms. The username is stored as a session variable $valid_user.
I keep getting a "query was empty" message from the following, it works fine for the first time, but when i try to read in a second test it gives me the query was empty.
<?
session_start();
$name = $valid_user;
?>
<html>
<head>
<title>Question results</title>
</head>
<body>
<h1>Results</h1>
<?
echo "You have completed section ". $section. " - ". $testid;
$val = array_sum($HTTP_POST_VARS);
mysql_connect("localhost", "root", "");
mysql_select_db("questions");
$result = mysql_query("SELECT * FROM questions WHERE Name='$name'");
$num = mysql_numrows($result);
if (!$num){
$query = "insert into questions (Name,$section) values
('$name','$val')";
}
else
{
mysql_query("UPDATE questions SET $section='$val' WHERE Name='$name'");
}
mysql_query($query) or die (mysql_error());
echo "<p>Your score for this section of the test is ". $val. ".<p>";
if ( array_sum($HTTP_POST_VARS) >= 51 )
{
echo $high;
}
else
{
echo $low;
}
echo '<p><A HREF="'. $next. '">Next Page</A>';
?>