开发者

update statement not effective

开发者 https://www.devze.com 2023-03-15 11:12 出处:网络
<?php . . . mysql_connect($host,$username,$password); if (!mysql_select_db($database)) die(\"Can\'t select database\");
<?php
.
.
.
mysql_connect($host,$username,$password);
if (!mysql_select_db($database))
    die("Can't select database");
$query="UPDATE table SET a='$A', b='$B', c='$C', WHERE id='$ID'";

$checkresult = mysql_query($query);
if ($checkresult) {
echo "Success";
} else {
echo "Sorry, it failed !";
}
mysql_close();
?>

The script will edit and replace the field with new information gained by input.

It will echo Success as expected, but the row开发者_JAVA百科 hasn't changed.

How can this be fixed?


change this:

$query="UPDATE table SET a='$A', b='$B', c='$C', WHERE id='$ID'";

with this:

$query="UPDATE table SET a='{$A}', b='{$B}', c='{$C}' WHERE id='{$ID}'";


There shouldn't be a comma before the "where". But I would think that would give you a syntax error, not get a bogus success return.

0

精彩评论

暂无评论...
验证码 换一张
取 消