Jump to content

Updating a MySQL entry


Prego

Recommended Posts

Hi,

I have been looking at this for hours now and figure that i need some help!

I need to create the query that updates a table upon submitting a form with a title value and an image.

Upon first submission the ID=1 entry is created. Upon second submission the ID=1 entry needs to be overwritten.

I separate the first submission from the second by an if statement.

if(mysql_num_rows(mysql_query("SELECT pID FROM $upix WHERE pID = '1'"))){
create first entry
}
else {
update first entry
}

However the syntax of the update script appears to be off.. Can anyone help?

 

 
mysql_query ("UPDATE $upix SET (title, imgdata) VALUES (\"".$_REQUEST[title]."\", \"". $image."\") WHERE pID='1'");

Many thanks and best regards.

Link to comment
https://forums.phpfreaks.com/topic/216882-updating-a-mysql-entry/
Share on other sites

The concatenation/quote escapement you're using is wrong, and not really even needed. Associative array index strings should be quoted, also.

 

mysql_query ("UPDATE $upix SET title = '{$_REQUEST['title']}', imgdata = '$image' WHERE pID = 1");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.