条款错误的Mysqli

时间:2016-06-14 22:52:43

标签: php mysql where-clause

当我使用像WHERE source_city = '$to_name'这样的单个where子句时,它工作正常但是当添加另一个检查时它会显示错误:

  

警告:mysqli_fetch_array()期望参数1为mysqli_result

    <?php  
        if(isset($_GET["view"])){
            $to_name = $_GET["to_name"];
            $from_name = $_GET["from_name"];
            $select_user = "SELECT * from citi 
                WHERE source_city = '$to_name' AND
                dest_city = '$from_name'";
            $run_user = mysqli_query($conn,$select_user);
            if(!$run_user){
                echo "Error!";
            }
            while ($row=mysqli_fetch_array($run_user)){
            $id = $row[0];
            $source_name = $row[1];
            $dest_name = $row[2];
            echo "
                    <br><br>
                    $id<br>
                    $source_name<br>
                    $dest_name<br>";

        }
    }

    ?>

1 个答案:

答案 0 :(得分:1)

muliple this语句的正确语法是:

WHERE

使用WHERE condition1 AND condition2 AND condition3 表示完整性:

OR