I want to insert a NULL value in a table column containing the phone area code with the following properties:
mediumint unsigned DEFAULT NULL
In my PHP script, I have this check to convert an empty string to NULL :
if($_POST['area_code'] == "") $_POST['area_code'] = NULL; // clean POST foreach($_POST as $field => $value) { $string[] = $field."=".$value; } $sql = "UPDATE Buyer SET ".implode(", ", $string)." WHERE user='$user'";
However, I get 0 instead of NULL . What needs to be done to insert NULL ?
source share