title: sql syntax error with ( possibly ) null entries
body: <p>Sorry for bother you with that kind of elementary questions. 
  I'm getting an error
      " You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 10". 
  Thanks in advance</p>
  
  <pre><code>&lt;?php
  $con=mysql_connect("localhost","......","......" );
  $database = "......";
  $ok = mysql_select_db($database, $con);
  mysql_set_charset("UTF8", $con);
  
  
  $us1 = $_POST['username1'];
  $sp1 = $_POST['startPoli1'];
  $fp1 = $_POST['finalPoli1'];
  $w1 = $_POST['weight1'];
  $dD1 = $_POST['depDate1'];
  $dT1 = $_POST['depTime1'];
  
  
  
  $sql = mysql_query( "  SELECT `username1`,`startPoli1`, `finalPoli1`,`weight1` , `depDate1` , `depTime1`, `tilefono1` 
   FROM customer ,registration1 
   where  ( 'sp1' is null or customer.startPoli1 = 'sp1') and 
   ( 'fp1' is null or customer.finalPoli1 = 'fp1') and 
   ( 'w1' is null or customer.weight1 = 'w1') and 
    ( 'dD1' is null or customer.depDate1 = 'dD1') and 
    ( 'dT1' is null or customer.depTime1 = 'dT1') and 
  
   (customer.username1 = registration1.username ");
  
      if($sql === FALSE) 
      { 
      die(mysql_error()); 
      }
      $results = array();
      while($row = mysql_fetch_assoc($sql))
  {
     $results[] = array(
          'username1' =&gt; $row['username1'],
          'startPoli1' =&gt; $row['startPoli1'],
          'finalPoli1' =&gt; $row['finalPoli1'],
          'weight1' =&gt; $row['weight1'],
          'depDate1' =&gt; $row['depDate1'],
          'depTime1' =&gt; $row['depTime1'],
          'tilefono1' =&gt; $row['tilefono1']
           );
           }
      echo json_encode(array('select_itin_results' =&gt;$results));
      mysql_close($con); 
  ?&gt;
  </code></pre>