patheticsam Posted February 28, 2009 Share Posted February 28, 2009 Hi! I have a form with checkboxes. I want to update an already existing entry in mySQL by adding the values selected from the checkboxes so I made an UPDATE sql command and I can't seem to get it working.... Here's the update code : <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tablename", $con); mysql_query(" UPDATE moving SET 1 = '{$_POST['values1']}', 2 = '{$_POST['values2']}', 3 = '{$_POST['values3']}', 4 = '{$_POST['values4']}' WHERE email = '{$_POST['email']}' AND movedate = '{$_POST['movedate']}'") or die(mysql_error()); ?> And here's the error that I get : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 = 'values1', 2 = 'values2', 3 = 'values3', 4 = 'values4', 5 = '', 6 ' at line 1 I've double checked everything and can't find what I'm doing wrong......Anyone can help? Thanx!!!!! Link to comment https://forums.phpfreaks.com/topic/147305-solved-problem-with-update-statement/ Share on other sites More sharing options...
supermerc Posted February 28, 2009 Share Posted February 28, 2009 Not sure but if I were you I'd try putting ` around your fields like mysql_query(" UPDATE moving SET `1` = '{$_POST['values1']}', `2` = '{$_POST['values2']}', `3` = '{$_POST['values3']}', `4` = '{$_POST['values4']}' WHERE email = '{$_POST['email']}' AND movedate = '{$_POST['movedate']}'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/147305-solved-problem-with-update-statement/#findComment-773234 Share on other sites More sharing options...
patheticsam Posted February 28, 2009 Author Share Posted February 28, 2009 It was it....I knew it wansn't something big....Thanks!!!! Link to comment https://forums.phpfreaks.com/topic/147305-solved-problem-with-update-statement/#findComment-773236 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.