Forum Moderators: coopster
<?php
//include '/home/www/juttuffi/auth.php';
include '/home/www/juttuffi/dbc.php';
$question = $_POST['quest'];
$answer = $_POST['answer'];
$nextq = $_POST['nextquest'];
$weight = $_POST['weight'];
$query1 = mysql_query("SELECT qid FROM tquestions WHERE question='$question'");
$qrow1 = mysql_fetch_array($query1,MYSQL_ASSOC);
$quest = $qrow1['qid'];
$sqlquery = "INSERT INTO tanswers (qid, answer, next_qid. weight) VALUES ('$quest','$answer','$nextq','$weight')";
//header("Location: index.php");
print $sqlquery;
$results = mysql_query($sqlquery);
mysql_close($dbc);
?>
Ok now this code outputs exactly what I want i want it to on the screen, that is it prints out the sql query which when i am submitting looks a little like this
INSERT INTO tanswers (qid, answer, next_qid. weight) VALUES ('3','BACK TO PREVIOUS','1','5')
The only problem is, the data i can see on screen doesn't appear to be appearing in the database table tanswers
can anyone tell me why the above code might not spit out any errors but at the same time doesn't appear to add to the database?
I would greatly appreciate the help here.
"INSERT INTO tanswers (qid, answer, next_qid. weight) VALUES ('3','BACK TO PREVIOUS','1','5')"
Should be ...
"INSERT INTO tanswers (qid, answer, next_qid, weight) VALUES ('3','BACK TO PREVIOUS','1','5')"
Also, i suggest you use a debuging method to see what the mysql error is.
e.g.
$results = mysql_query($sqlquery);
Could be.
$results = mysql_query($sqlquery) or die(mysql_error());
This will output the exact error and give you a better idea of what the prolem could be.
Hope i have helped.
Del