steveangelis Posted June 12, 2010 Share Posted June 12, 2010 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 More sharing options...
steveangelis Posted June 12, 2010 Author Share Posted June 12, 2010 Never mind, the $id2 needed ' ' around it. Hence the stupid error. Thank you anyways. Link to comment https://forums.phpfreaks.com/topic/204575-stupid-error/#findComment-1071151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.