What I'm trying to do is that every time the page loads to get a field in my DB named ‘Counter’ to add one to itself.
I have some code but I know its wrong because it return NULL
Code: Select all
function update(){
$updateSQL = sprintf("UPDATE CONTENT SET Counter=%s WHERE contentID=%s",
GetSQLValueString($row_ShowContent['Counter'], "int"),
GetSQLValueString($row_ShowContent['contentID'], "int"));
mysql_select_db($database_DinamicPortfolio, $DinamicPortfolio);
$Result1= mysql_query($updateSQL, $DinamicPortfolio) or die(mysql_error());
echo ("$updateSQL");
# UPDATE CONTENT SET Counter=NULL WHERE contentID=NULL
}
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;
}