Jump to content

UPDATE statement problems


woodplease

Recommended Posts

I'm posting values to a page so that i can use them to update a table. i know that the values have been posted because i have echoed them out on the other page. My problem is that whenever i load the page, i keep getting the following error:

 

Warning: pg_query() [function.pg-query]: Query failed: ERROR: parser: parse error at or near "question" in /berw/ugrad1/base/a/agd8/public_html/quizdom/questionupdated2.php on line 35

 

the code i'm using is

<?php
$quizno = $_POST['quizno'];
$questionno=$_POST['questionno'];
$question=$_POST['question'];
?>
<?php
$id = $_GET['id'];
echo'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><link rel="stylesheet" type="text/css" href="sheet1.css" />
<meta http-equiv="content-type" 
	content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>Add Questions to a Quiz</title>
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="maincontent">';
echo $quizno; //echoing out to see if values have been posted
echo $questionno;//echoing out to see if values have been posted
echo $question;//echoing out to see if values have been posted

$query="UPDATE questions SET question=".$question. "WHERE quizref=".$quizno."AND questionno=".$questionno;
$result = pg_query($query) or die ("Query failed");
echo' Question updated';

echo'
</div>
</div>
</body>
</html>'
?>

Any ideas on this would be great

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/190776-update-statement-problems/
Share on other sites

I'm posting values to a page so that i can use them to update a table. i know that the values have been posted because i have echoed them out on the other page. My problem is that whenever i load the page, i keep getting the following error:

 

Warning: pg_query() [function.pg-query]: Query failed: ERROR: parser: parse error at or near "question" in /berw/ugrad1/base/a/agd8/public_html/quizdom/questionupdated2.php on line 35

 

the code i'm using is

$query="UPDATE questions SET question=".$question. "WHERE quizref=".$quizno."AND questionno=".$questionno;

Any ideas on this would be great

 

Thanks

 

Ditch the "s and swap them for ' within the query statement  and split it down like this:

 

$query="UPDATE questions SET question='$question' WHERE quizref='$quizno' AND questionno='$questionno'"

 

 

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.