Andrew R Posted September 21, 2006 Share Posted September 21, 2006 Can anybody tell me why this script for updating a database is not working? The problem is I keep getting an error message, Warning: sprintf(): Too few arguments in ..... on line .... Query was empty[code]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["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE text SET id=%s, text=%s WHERE id=%s", GetSQLValueString($_POST['text'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_conn_abrv, $conn_abrv); $Result1 = mysql_query($updateSQL, $conn_abrv) or die(mysql_error()); $updateGoTo = ""; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo));}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21565-script-help/ Share on other sites More sharing options...
Daniel0 Posted September 21, 2006 Share Posted September 21, 2006 Make sure the variables you pass to sprintf is actually set. Quote Link to comment https://forums.phpfreaks.com/topic/21565-script-help/#findComment-96247 Share on other sites More sharing options...
Andrew R Posted September 22, 2006 Author Share Posted September 22, 2006 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/21565-script-help/#findComment-96728 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.