title: PHP: insert NULL if input value is empty
body: <p>i have been trying to insert <em>NULL</em> to my database if the value of input is empty
  but i still it insert <code>empty and NULL string</code></p>
  
  <p>Here's my code</p>
  
  <p>this code returns blank</p>
  
  <pre><code>  if (empty($_POST['caller'])){ $caller= NULL; }else{ $caller =  mysqli_real_escape_string($con, $_POST['caller']);}
  
    or this
  
    $caller =  mysqli_real_escape_string($con, $_POST['caller']);
    $caller = !empty($caller_contact) ? "'$caller'" : NULL;
  </code></pre>
  
  <p>this code returns NULL string</p>
  
  <pre><code>  $caller =  mysqli_real_escape_string($con, $_POST['caller']);
    $caller = !empty($caller_contact) ? "'$caller'" : 'NULL';
  
   or this
  
    if (empty($_POST['caller'])){ $caller= 'NULL'; }else{ $caller =  mysqli_real_escape_string($con, $_POST['caller']);}
  </code></pre>
  
  <p>query</p>
  
  <pre><code>$sql_caller = "INSERT INTO `tblcall_info` VALUES ('','$save_inc_id','$call_time','$call_date','$caller','$caller_contact','$receiver','$device')";
  </code></pre>
  
  <p>i have also tried changing <code>'$caller'</code> to <code>$caller</code> but its an error.</p>
  
  <p><a href="https://i.stack.imgur.com/UpxeA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UpxeA.jpg" alt="enter image description here"></a>
  can anyone help?. thanks</p>