My table has two columns – col1 (int, null) and col2 (int, null) which I want to be able update with an empty values or null statement.
My code looks like:
$newkeylimit = $allkeylimits[$row['Group_ID']];
if($newkeylimit == ''){ $newkeylimit = NULL ; }
$newproflimit = $allproflimits[$row['Group_ID']];
if($newproflimit == ''){ $newproflimit = NULL ; }
$sql = "UPDATE ".$mssql_table_prefix."Groups SET Group_Name = '".$newgroupname."', col1 = '".$newkeylimit."', col2 = '".$newproflimit."' WHERE Group_ID = '".$row['Group_ID']."'";
$result = mssql_query($sql)
or die( "<strong>ERROR: Group update query failed</strong>" );
After code execution I’m getting 0 in each column where suppose to be an empty value or NULL. Default values for col1 and col2 are set to NULL.
Any idea what I’m doing wrong? Thanks
You are passing a string instead of NULL to the server. Get rid of the apostrophes (‘) for col1 and col2.