woodplease Posted February 3, 2010 Share Posted February 3, 2010 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 More sharing options...
jl5501 Posted February 3, 2010 Share Posted February 3, 2010 you need a space inside the quotes, before WHERE " WHERE... Link to comment https://forums.phpfreaks.com/topic/190776-update-statement-problems/#findComment-1006009 Share on other sites More sharing options...
Bottyz Posted February 3, 2010 Share Posted February 3, 2010 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'" Link to comment https://forums.phpfreaks.com/topic/190776-update-statement-problems/#findComment-1006010 Share on other sites More sharing options...
woodplease Posted February 3, 2010 Author Share Posted February 3, 2010 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'" Thanks very, much, it works now Link to comment https://forums.phpfreaks.com/topic/190776-update-statement-problems/#findComment-1006081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.