Prego Posted October 26, 2010 Share Posted October 26, 2010 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 More sharing options...
PFMaBiSmAd Posted October 26, 2010 Share Posted October 26, 2010 http://dev.mysql.com/doc/refman/5.0/en/update.html Link to comment https://forums.phpfreaks.com/topic/216882-updating-a-mysql-entry/#findComment-1126665 Share on other sites More sharing options...
Prego Posted October 26, 2010 Author Share Posted October 26, 2010 I've read the manual but mysql_query ("UPDATE $upix SET title='\"".$_REQUEST[title]."\"', imgdata= '\"". $image."\"' WHERE pID='1'"); Doesn't seem to work either.. Any thoughts? Link to comment https://forums.phpfreaks.com/topic/216882-updating-a-mysql-entry/#findComment-1126666 Share on other sites More sharing options...
Pikachu2000 Posted October 26, 2010 Share Posted October 26, 2010 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"); Link to comment https://forums.phpfreaks.com/topic/216882-updating-a-mysql-entry/#findComment-1126679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.