virusbogdan
virusbogdan

Reputation: 187

update statement not effective

<?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 hasn't changed.

How can this be fixed?

Upvotes: 2

Views: 83

Answers (2)

Jay
Jay

Reputation: 27464

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.

Upvotes: 0

JellyBelly
JellyBelly

Reputation: 2431

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}'";

Upvotes: 1

Related Questions