To pass a NULL to MySQL, you do just that.
$notes = !empty($notes) ? "'$notes'" : "NULL"; $query = "INSERT INTO data (name, notes) VALUES ('name',$notes)";
or you could add condition like…
$query = "INSERT INTO data (name, notes) VALUES ('name',NULLIF('$notes',''))";
Article Categories:
PHP