title: Insert NULL values to MySql records using MySqli
body: <p>My page sends using ajax data to a php script. one of the vars that the script gets is: $product_disc
  now a small test that I have done inside the script clearly revealed that $product_disc is null. the test:</p>
  
  <pre><code>if ($product_disc == null)
   {$test="null";}
   else {$test="not null";}
  </code></pre>
  
  <p>I make my code return $test to the ajax calling procedure:</p>
  
  <pre><code>$return_array['success'] = array ('test' =&gt; $test);
  </code></pre>
  
  <p>And using Firebug I see that the ajax response has: "test":"null"<br>
  So i conclude that $product_disc is of value: null</p>
  
  <p>Now, inside my script I'm using the following code to insert data to MySql DB:</p>
  
  <pre><code>$stmt = mysqli_prepare($link, "INSERT INTO set_products (id,discount) VALUES (NULL , ?)");
  mysqli_stmt_bind_param($stmt, "i", $product_disc);
  mysqli_stmt_execute($stmt);
  mysqli_stmt_close($stmt);
  </code></pre>
  
  <p>The query is being executed, but the value that was inserted is 0 and not NULL!<br>
  Only when I explicitly added: $product_disc=null; before the MySqli statements, the value that was inserted was NULL.</p>
  
  <p>Why is that? What's the different between a null and a null? I followed this <a href="https://stackoverflow.com/questions/5329542/php-mysql-insert-null-values">answer</a> in stackoverflow hoping that i could easily insert NULLs but then came this problem...</p>
  
  <p>Thank you!</p>
  
  <p>PS @stackoverflow team - Your spell checking dictionary doesn't recognize the word stackoverflow!</p>