bcraig Posted December 21, 2007 Share Posted December 21, 2007 Can anyone tell me why im getting this error Im using: PHP 5.2.5 MySql 5.0.45 Apache 2.2.6 Windows XP localhost 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 id=41' at line 1 This is my code <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["update"])) && ($_POST["update"] == "updateAuction")) { $updateSQL = sprintf("UPDATE auctions SET title=%s, current_price=%s, description=%s, quals=%s, refs=%s, materials=%s, deadline=%s, day=%s, location=%s, payment=%s, WHERE id=%s", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['current_price'], "int"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString($_POST['quals'], "text"), GetSQLValueString($_POST['refs'], "int"), GetSQLValueString($_POST['materials'], "text"), GetSQLValueString($_POST['deadline'], "date"), GetSQLValueString($_POST['day'], "text"), GetSQLValueString($_POST['location'], "text"), GetSQLValueString($_POST['payment'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_jobsnz_conn, $jobsnz_conn); $Result1 = mysql_query($updateSQL, $jobsnz_conn) or die(mysql_error()); $updateGoTo = "success.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82631-solved-update-error/ Share on other sites More sharing options...
rajivgonsalves Posted December 21, 2007 Share Posted December 21, 2007 payment=%s, WHERE should be payment=%s WHERE Quote Link to comment https://forums.phpfreaks.com/topic/82631-solved-update-error/#findComment-420268 Share on other sites More sharing options...
bcraig Posted December 21, 2007 Author Share Posted December 21, 2007 Ahhh silly little typo Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/82631-solved-update-error/#findComment-420285 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.