title: PHP/mySQL INSERT NULL if variable is empty
body: <p>i want to check if a variable from <code>$_POST</code> is empty and INSERT a NULL to my Database.</p>
  
  <p>But when I do it my way i always get a String called NULL and not a real NULL in my data set.<br>
  This is how I tried it:</p>
  
  <pre><code>if(isset($_POST['folge'])){
      $comment = !empty($_POST['comment']) ? "'".$_POST['comment']."'" : null;
  
      $sqlstring = "INSERT INTO eventstest (comment) VALUES (".$comment.")";
      echo $sqlstring;
      if ($mysqli-&gt;query($sqlstring) === TRUE) {
        printf("Table myCity successfully created.\n");
      }else{
        printf("Errorcode: %d\n", $mysqli-&gt;errno);
          printf("Error: %d\n", $mysqli-&gt;error);
      }
  </code></pre>
  
  <p>if I send the form without making inputs to "comment" page output is:</p>
  
  <blockquote>
    <p>INSERT INTO eventstest (comment) VALUES ()Errorcode: 1136 Error: 0 </p>
  </blockquote>
  
  <p>Whats wrong? Or whats the better way to check for empty inputs and add NULL to DB?</p>
  
  <p>PS: The database cell has STANDARD: NULL</p>