简体   繁体   中英

Execute Mysql query in php

I'm sure I'm getting the vaue of $bn and $answer on my page now I just want to insert the value in the column answer value $answer where qid is $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";
}
?>

INSERT语句不支持WHERE子句。

Syntax on how to write an INSERT statement.

Do you want to update the database or insert? INSERT will not work with WHERE clause.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM