Update not working

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
exutable
Forum Newbie
Posts: 5
Joined: Wed Feb 16, 2005 7:35 pm

Update not working

Post 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);

}
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

exutable, I'd recommend echoing out the query string, to make sure it's coming out right.
thurstan
Forum Commoner
Posts: 28
Joined: Mon Feb 28, 2005 7:40 am

Post 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!
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply