Hi this code which I have used on at least three different servers fails under my configuration of php5:
Could anyone help me see if it is a bug or a configuration error?
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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
$insertSQL = sprintf("INSERT INTO tbl_help (title, copy, date) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['EditorValue'], "text"),
GetSQLValueString($_POST['date'], "text"));
mysql_select_db($database_hadb, $hadb);
$Result1 = mysql_query($insertSQL, $hadb) or die(mysql_error());
You have an error near... 'How to.... etc, etc...