Jump to content

Stupid Error


steveangelis

Recommended Posts

For the life of me I cannot figure out where the error in this code is:

 

$q_test3 = mysql_query("select * from ans2 where test_id='$id' order by id asc") or die(mysql_error());
while ($g_test3 = mysql_fetch_array($q_test3))$num_ans = $num_ans+1;
{
$var = "q2a".$num_ans;
$var2 = "corans".$num_ans;
$ans = $_POST[$var];
$chk = $_POST[$var2];
$id2 = $g_test3['id'];
mysql_query("update ans2 set ans='$ans', corans='$chk' where id=$id2")or die(mysql_error());
}

 

I stripped the code down to only the parts that could potentially be affecting the error.  I am getting the following error:

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

I have checked all the needed variables, and $ans and $chk both are producing results from the previous form (The num_ans is a number always going up by one which is needed for this script).  The $ans field comes from a text box and $chk is a check box.  My test is running 4 fields right now, and the first entry updates without a problem but the next one produces this error.  Any ideas?

 

Edit:  I noticed that it is updating the first entry but it is not producing a confirmation after the update that is needed.  IE The tables are all updated but the error is coming from the first entry.

Link to comment
https://forums.phpfreaks.com/topic/204575-stupid-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.