MySQL - PHP UPDATE query problem...
Posted: Sat Mar 19, 2005 2:16 pm
Hi all,
I'm creating an assesment and Feedback system and I'm using an UPDATE statement to enter $feedback into the required record depending on testno, questionno and answerno, Using a PHP script shown below: My problem is that when running it, I get the following error:
"Unknown column 'feedback' in 'field list'"
However "feedback" defiantly does exist (feedback, feedback2, feedback3, feedback4 - in my database table "test". And "feedback" text box in html web form assigned to variable $feedback using POST). Any ideas? Any help will be much appreciated.
Regards,
Simon.
PHENOM | USE
I'm creating an assesment and Feedback system and I'm using an UPDATE statement to enter $feedback into the required record depending on testno, questionno and answerno, Using a PHP script shown below: My problem is that when running it, I get the following error:
"Unknown column 'feedback' in 'field list'"
However "feedback" defiantly does exist (feedback, feedback2, feedback3, feedback4 - in my database table "test". And "feedback" text box in html web form assigned to variable $feedback using POST). Any ideas? Any help will be much appreciated.
Regards,
Simon.
Code: Select all
<?php
$conn = @mysql_connect( "linuxproj", "****", "****" )
or die( mysql_error() );
#select the specified database
$rs = @mysql_select_db ( "db_sn202", $conn )
or die( mysql_error() );
phpinfo();
$testname = $_POST['testname'];
$questionno = $_POST['questionno'];
$answerno = $_POST['answerno'];
$feedback = $_POST['feedback'];
$qry="select testno from test where testname = ('$testname')";
$rs = mysql_query( $qry, $conn )
or die( mysql_error() );
$row=mysql_fetch_object($rs);{
$testno = $row->testno;
Switch($answerno)
{
Case '1' :
$sql="update question set feedback = '$feedback' where
testno = '$testno' and questionno = '$questionno'";
$rs2 = mysql_query( $sql, $conn )
or die( mysql_error() );
break;
Case '2' :
$sql2="update question set feedback2 = '$feedback' where
testno = '$testno' and questionno = '$questionno'";
$rs3 = mysql_query( $sql2, $conn )
or die( mysql_error() );
break;
Case '3' :
$sql3="update question set feedback3 = '$feedback' where
testno = '$testno' and questionno = '$questionno'";
$rs4 = mysql_query( $sql3, $conn )
or die( mysql_error() );
break;
Case '4' :
$sql4="update question set feedback4 = '$feedback' where
testno = '$testno' and questionno = '$questionno'";
$rs5 = mysql_query( $sql4, $conn )
or die( mysql_error() );
break;
}
}
?>Code: Select all
TAGS FOR PHP [/color]