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

```
<?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' => $row['username1'],
        'startPoli1' => $row['startPoli1'],
        'finalPoli1' => $row['finalPoli1'],
        'weight1' => $row['weight1'],
        'depDate1' => $row['depDate1'],
        'depTime1' => $row['depTime1'],
        'tilefono1' => $row['tilefono1']
         );
         }
    echo json_encode(array('select_itin_results' =>$results));
    mysql_close($con); 
?>

```