Page 1 of 1

MySQL - PHP UPDATE query problem...

Posted: Sat Mar 19, 2005 2:16 pm
by sn202
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.

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; 
    } 
} 
?>
PHENOM | USE

Code: Select all

TAGS FOR PHP   [/color]

Posted: Sat Mar 19, 2005 2:22 pm
by John Cartwright
$rs = @mysql_select_db ( "db_sn202", $conn )



you are not selecting the correct database :wink:

edit-misread your post, sorry

Posted: Sat Mar 19, 2005 2:31 pm
by sn202
No, it is the correct database, the only database I have access to on that server. If it was an incorrect database then it would display an access denied error...

Posted: Sat Mar 19, 2005 2:35 pm
by John Cartwright
can you show me the table strucuture of "test"

Posted: Sat Mar 19, 2005 2:47 pm
by sn202
Yeah sure, below is the database schema for both test and question:

TEST
testno
testname


QUESTION
quesitonid
testno *
questionno
heading1
heading2
question
imgurl
answer1
truefalse
feedback
answer2
truefalse2
feedback2
answer3
truefalse3
feedback3
answer4
truefalse4
feedback4

I have two PHP - MySQL scripts acting upon these tables. The first enters: questionno, heading1, heading2, question, imgurl, answer1, truefalse, answer2, truefalse2, answer3, truefalse3, answer4, truefalse4. into question and testname into test.

The second is the one shown, which enters feedback into the relative feedback record.

Simon.