title: Insert in mysql from php saves a date field as 00:00:00 instead of NULL
body: <p>I receive via POST the following variables, sometimes it must be a date and sometimes it must be null (for example if that event has not happened yet)</p>
  
  <pre><code>$hora_entrada = $_POST['hora_entrada'];
  $salida_comida = $_POST['salida_comida'];
  $regreso_comida = $_POST['regreso_comida'];
  $hora_salida = $_POST['hora_salida'];
  </code></pre>
  
  <p>so, I assign NULL into the variables if POST is empty:</p>
  
  <pre><code>if ($hora_entrada == '') {$hora_entrada = "NULL";}
  if ($salida_comida == '') {$salida_comida = "NULL";}
  if ($regreso_comida == '') {$regreso_comida = "NULL";}
  if ($hora_salida == '') {$hora_salida = "NULL";}
  </code></pre>
  
  <p>now, I want to insert the values into a mysql table:</p>
  
  <pre><code>UPDATE  `nomina`.`registro_tiempo` SET  
  `hora_entrada` =  '$hora_entrada',
  `salida_comida` =  '$salida_comida',
  `regreso_comida` =  '$regreso_comida',
  `hora_salida` =  '$hora_salida',
  WHERE  `registro_tiempo`.`id_tiempo` ='$id_tiempo';
  ") or die (mysql_error());
  </code></pre>
  
  <p>the problem is that when the variable is NULL the record says 00:00:00 and I want to keep it NULL</p>
  
  <p>I tried to assign NULL in this two ways without success:</p>
  
  <pre><code>$variable = NULL;
  
  $variable = "NULL";
  </code></pre>
  
  <p>NOTE: The MySql fields have the NULL value as Predetermined.</p>
  
  <p>¿Do you know any other way to do this? I will apreciate your help</p>