here is my code
$q = "UPDATE" 'questions' SET 'answer' = .$_POST["question-".$x]."WHERE 'questions'.'number' = ".$x;
its saying the single quotes around question and probably answer are syntax errors "Parse error: syntax error, unexpected single-quoted string "questions" in C:\xampp2.0\htdocs\surveypages.php on line 29" but when I change them to double quotes it gives the same thing but for double quotes
i dont know if it helps but its connecting to a MySQL database
CodePudding user response:
$q = "UPDATE 'questions' SET 'answer' = '" .
mysql_real_escape_string ($_POST["question-".$x]) .
"' WHERE 'questions'.'number' = ". mysql_real_escape_string($x);
CodePudding user response:
The way you distributed the quotes is the problem.
Try :
$q = "UPDATE questions SET answer = " .$_POST['question-.$x'] . " WHERE questions.number = $x";
Also keep in mind that this format of passing data directly in the query is subject to sql injection.
Check this out How to prevent sql injection