xxreenaxx1 Posted March 25, 2011 Share Posted March 25, 2011 I have a code that works but it wont add the data to my database. It says the data has been added but the actual data is not actually added. I have checked through this code to see any errors but I cant find any. Can someone help me $sqll= takeanexam($_SESSION['username1'], $_SESSION['ssubject'], $_SESSION['smodule']); // mysql_data_seek(sqll, 0); while($info = mysql_fetch_array( $sqll )) { $questionId = $info['Que_ID']; $choice = array(); for ($i =1; $i < 5; $i++) { if (empty($_POST['choice'][$questionId][$i])) { $choice[$i] = 0; } else { $choice[$i] = 1; } } $username= $_SESSION['username1']; mysql_query("INSERT INTO answer (Ans_Answer1, Ans_Answer2, Ans_Answer3, Ans_Answer4, Que_ID, Use_ID) VALUES ({$choice[1]}, {$choice[2]}, {$choice[3]}, {$choice[4]}, $questionId, $username)"); } Quote Link to comment Share on other sites More sharing options...
sunfighter Posted March 26, 2011 Share Posted March 26, 2011 This may be a stupid question but why do you have $choice[1] $choice[2] $choice[3] $choice[4] in curly brackets? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 26, 2011 Share Posted March 26, 2011 The {} are not necessary in this case, but don't hurt anything. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.