Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql sql语法错误,有(可能)空条目_Mysql_Sql - Fatal编程技术网

Mysql sql语法错误,有(可能)空条目

Mysql sql语法错误,有(可能)空条目,mysql,sql,Mysql,Sql,很抱歉用这些基本问题来打扰你。 我犯了个错误 “您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以了解第10行“”附近使用的正确语法。”。 提前谢谢 <?php $con=mysql_connect("localhost","......","......" ); $database = "......"; $ok = mysql_select_db($database, $con); mysql_set_charset("UTF8", $con); $us1 = $

很抱歉用这些基本问题来打扰你。 我犯了个错误 “您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以了解第10行“”附近使用的正确语法。”。 提前谢谢

<?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); 
?>

您在最后一个where条件中缺少右括号

这个
(customer.username1=registration1.username”);
应该是:
(customer.username1=registration1.username)”

SQL末尾缺少一个圆括号(或在最后一个条件中有多余的不必要的圆括号)

这就是您的SQL:

( "  SELECT `username1`,`eidosmetaf1`,`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 ");
使用


我添加了圆括号,现在我在第27行的C:\xampp\htdocs\etruck1\select_itin.php中得到了“Parse error:syntax error,unexpected”)“您在哪里添加了圆括号?您的SQL现在是什么样子的?请参见上面的查询,尤其是customer.username1,没有圆括号。
( "  SELECT `username1`,`eidosmetaf1`,`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 ");