Page 1 of 1
Update not working
Posted: Sat Feb 19, 2005 11:03 pm
by exutable
Hey I have this update script but there is a problem it doesn't actually update the table it just makes it blank in every field!
Code: Select all
function edittag($id, $name, $email, $message) {
$result = "UPDATE tagwall set name='$name', email='$email', message='$message' where id=$id";
mysql_query($result);
}
Posted: Sat Feb 19, 2005 11:07 pm
by thegreatone2176
change to
Code: Select all
$result = "UPDATE tagwall SET name='$name', email='$email', message='$message' WHERE id='$id'";
I just captialized set and where and you needed ' around $id like you did around every other variable
Posted: Sat Feb 19, 2005 11:29 pm
by feyd
exutable, I'd recommend echoing out the query string, to make sure it's coming out right.
Posted: Wed Mar 02, 2005 5:37 am
by thurstan
I too am having this same problem, when I try to amend a record via a form the record just goes bank, here's my UPDATE code:
Code: Select all
$sql = "UPDATE img_table SET img_data='$img_data', project='$project', description='$description', date='$date' WHERE id='$id'";
I can't see anything wrong with this, does anybody know why it's blanking out the records? thanks!
Posted: Wed Mar 02, 2005 5:48 am
by CoderGoblin
feyd wrote:exutable, I'd recommend echoing out the query string, to make sure it's coming out right.
As always... He's right. echo the string and check if the parameters are being passed in correctly and building the $sql variable as expected.