MySQL insert NULL value after getting value with $_REQUEST <p>I have input fields, but if the users leave it blank, i want to insert a null value to my database.</p> <p>I request values like this:</p> <pre><code>$val1 = htmlspecialchars($_REQUEST["val"], ENT_QUOTES); </code></pre> <p>And then insert them to the DB:</p> <pre><code>INSERT INTO `table` ( `val1` , `val2` , `val3`) VALUES ('$val1', '$val2', '$val3'); </code></pre> <p>I have tried removing the ' around val1, val2, val3 - but then nothing gets inserted into the DB if there is no value. I have also tried something like this:</p> <pre><code>if (!empty($val1)) { $val1 = "'".$val1."'"; } else { $val1 = NULL;} </code></pre> <p>And then without the ' around the values - still no insert to the DB</p>