在php中执行Mysql查询

时间:2014-03-21 09:43:18

标签: php sql

我确定我现在在页面上获得$bn$answer的值我只想在列回答值$answer中插入值其中qid是$bn

<?php

$answer = $_POST['one'];
$an = $_POST['two'];
$bn = $an - 1;
echo "$bn";
$con = mysql_connect('localhost', 'root', 'pankaj') or die(mysql_error());
$db = mysql_select_db('quiz', $con) or die(mysql_error());
$q = "INSERT INTO question(uanswer) VALUE '" . $answer . "' where qid='" . $bn . "'";
$rq = mysql_query($q, $con);
if (!$rq) {
    echo " the sql query faiiled to work ";
} else {
    echo "the query executed sucessfully";
}
?>

2 个答案:

答案 0 :(得分:1)

INSERT语句不支持WHERE子句。

Syntax on how to write an INSERT statement.

答案 1 :(得分:1)

您要更新数据库还是插入? INSERT不适用于WHERE条款。