xiaoxin22 Posted December 14, 2009 Share Posted December 14, 2009 below is the sql query i typed for my php.. i'm trying to update my database through the $_POST i got from the previous page but couldn't work. there's syntax error. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) { $updateSQL = sprintf("UPDATE user SET user_company=%s, user_contact=%s, user_ic=%s, user_pw=%s, WHERE user_email=%s", GetSQLValueString($_POST['Company'], "text"), GetSQLValueString($_POST['Contact'], "text"), GetSQLValueString($_POST['IC'], "text"), GetSQLValueString($_POST['Password'], "text"), GetSQLValueString($_SESSION['MM_Username'], "text")); mysql_select_db($database_db_crm, $db_crm); $Result1 = mysql_query($updateSQL, $db_crm) or die(mysql_error()); $updateGoTo = "update_success.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } this is the syntax error i got. 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 'WHERE user_email='[email protected]'' at line 1 Hope my informations is enough. Thank You. Link to comment https://forums.phpfreaks.com/topic/185052-help-update-syntax-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 14, 2009 Share Posted December 14, 2009 You already have a thread for this problem. Don't start another one. Link to comment https://forums.phpfreaks.com/topic/185052-help-update-syntax-error/#findComment-976806 Share on other sites More sharing options...
Deoctor Posted December 14, 2009 Share Posted December 14, 2009 check this out GetSQLValueString($_SESSION['MM_Username'], "text")); i think if u remove the GetSQLValueString it will work.. Link to comment https://forums.phpfreaks.com/topic/185052-help-update-syntax-error/#findComment-976810 Share on other sites More sharing options...
Buddski Posted December 14, 2009 Share Posted December 14, 2009 you have an un-needed comma before your WHERE clause... Link to comment https://forums.phpfreaks.com/topic/185052-help-update-syntax-error/#findComment-976815 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.