geroid Posted April 27, 2009 Share Posted April 27, 2009 Can you help with this update statement. I get the following error message: Could not insert data because 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 ')' at line 1 The code I'm using is: $insert = mysql_query("update $table set event_name='" .$_SESSION['evname']. "', venue_name='".$_SESSION['venuename']."', streetaddress1='".$_SESSION['addr1']."', town='".$_SESSION['town']."', county='".$_SESSION['county']."', event_description='".$_SESSION['content']."', event_date='".$_SESSION['fulldate']."', event_time='".$_SESSION['time']."' where event_num = '".$_SESSION['editwhatrecord']."')") or die("Could not insert data because ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/ Share on other sites More sharing options...
Maq Posted April 27, 2009 Share Posted April 27, 2009 You have an extra closing parenthesis. Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820399 Share on other sites More sharing options...
geroid Posted April 27, 2009 Author Share Posted April 27, 2009 Sorry Maq I don't understand. Could you be more specific? Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820442 Share on other sites More sharing options...
revraz Posted April 27, 2009 Share Posted April 27, 2009 ".$_SESSION['editwhatrecord']."')") <----- Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820444 Share on other sites More sharing options...
mattal999 Posted April 27, 2009 Share Posted April 27, 2009 Your query should be: $insert = mysql_query("update $table set event_name='" .$_SESSION['evname']. "', venue_name='".$_SESSION['venuename']."', streetaddress1='".$_SESSION['addr1']."', town='".$_SESSION['town']."', county='".$_SESSION['county']."', event_description='".$_SESSION['content']."', event_date='".$_SESSION['fulldate']."', event_time='".$_SESSION['time']."' where event_num = '".$_SESSION['editwhatrecord']."'") or die("Could not insert data because ".mysql_error()); You had an extra ) in there after 'where event_num..."' Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820446 Share on other sites More sharing options...
Maq Posted April 27, 2009 Share Posted April 27, 2009 EDIT: There you go. --^ Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820449 Share on other sites More sharing options...
Cosizzle Posted April 27, 2009 Share Posted April 27, 2009 it means that you have one to many ) somewhere... do you get an error saying line number? Maq's code will show errors Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820450 Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2009 Share Posted April 27, 2009 If you form your queries in a variable and then put that variable into the mysql_query statement, it will keep the syntax of the query separate from the syntax of the code running the query and it will be easier to see problems like that. Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820457 Share on other sites More sharing options...
geroid Posted April 27, 2009 Author Share Posted April 27, 2009 Thanks everyone that worked great. Everything is fine now Quote Link to comment https://forums.phpfreaks.com/topic/155869-solved-sql-update-statement-not-working/#findComment-820475 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.