<?php<br />
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />
{<br />
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;<br />
<br />
switch ($theType) {<br />
case "text":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break; <br />
case "long":<br />
case "int":<br />
$theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />
break;<br />
case "double":<br />
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br />
break;<br />
case "date":<br />
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />
break;<br />
case "defined":<br />
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />
break;<br />
}<br />
return $theValue;<br />
}<br />
<br />
$editFormAction = $_SERVER['PHP_SELF'];<br />
if (isset($_SERVER['QUERY_STRING'])) {<br />
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />
}<br />
<br />
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {<br />
$updateSQL = sprintf("Update artcat SET catname=%s, list=%s, pid=%s, view
=%s, catcon=%s, menu=%s, ruby=%s Where id=%s",<br />
GetSQLValueString($_POST['catname'], "text"),<br />
GetSQLValueString($_POST['list'], "int"),<br />
GetSQLValueString($_POST['pid'], "int"),<br />
GetSQLValueString(isset($_POST['view']) ? "true" : "", "defined","1","0"),<br />
GetSQLValueString($_POST['catcon'], "text"),<br />
GetSQLValueString(isset($_POST['menu']) ? "true" : "", "defined","1","0"),<br />
GetSQLValueString(isset($_POST['ruby']) ? "true" : "", "defined","1","0"),<br />
GetSQLValueString($_POST['id'], "int"));<br />
<br />
mysql_select_db($database_db, $db);<br />
$Result1 = mysql_query($updateSQL, $db) or die(mysql_error());<br />
}<br />
?>