<?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.
精彩评论