Jump to content

why wont the data added to the database.


xxreenaxx1

Recommended Posts

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

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.