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)"); } Link to comment https://forums.phpfreaks.com/topic/231678-why-wont-the-data-added-to-the-database/ 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? Link to comment https://forums.phpfreaks.com/topic/231678-why-wont-the-data-added-to-the-database/#findComment-1192546 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. Link to comment https://forums.phpfreaks.com/topic/231678-why-wont-the-data-added-to-the-database/#findComment-1192549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.