Can anyone help with is code. I cannot insert values into Questionnaire....
I have tried using different methods but it is not working. Is there any error that I have made?
This is the main problem:
$query = "INSERT INTO Questionnaire VALUES (' ', '$unit_id', '$quest_id')";
$result = mysql_query($query);
.........................................................................................................
Part of the code start here
[ php ] $qtype_id = $POST['qtype_id'];
//$unit_id = $POST['unit_id'];
$query = "INSERT INTO Questions VALUES ( ' ', '$q', '$qtype_id')";
$result = mysql_query($query);
$quest_id = mysql_insert_id();
$query2 = "SELECT unit_id FROM Units WHERE unit_name='B302'";
//$result = mysql_query ($query);
$result = mysql_query ("SELECT unit_id FROM Units") or die ("Invalid query");
$unit_id = mysql_insert_id();
$query = "INSERT INTO Questionnaire VALUES (' ', '$unit_id', '$quest_id')";
$result = mysql_query($query);
if ($result) { // if it ran ok
echo '<p>Question is registered in database.</p>';
exit(); //Quit script.
} else { // Something is not right.
$message = '<p>Please go back and refill form.</p><p> ' . mysql_error() . '</p>';
}
mysql_close(); // Close database connection
} else { // Display the form.
}
// Print the error message if there is one
if(isset($message)) {
echo '<font color="red">', $message, '</font>'; [ /php]