dragon012100 2015-08-26 00:49
浏览 26
已采纳

PHP无法在SQL中使用订单,但它在[关闭]之前有效

After adding this line 'order by Fines($)', it always said: Problem Query. when I delete die(problem query)function, it said cannot find the parameters.

<?php

if(isset($_POST["searchBtn"]))
{
    $strInputSuburb = "";
    $strInputStreet = "";

    $strInputSuburb = $_POST["suburb"];
    $strInputStreet = $_POST["street"];

    if(!empty($strInputSuburb) || !empty($strInputStreet))
    {
        $conn = @mysqli_connect("localhost", "example", "exmaple")
        or die ("Failed to connect server");
        @mysqli_select_db($conn, "example")
        or die ("Database not available");

        $querySql1 = "select * from Infringement 
                      where suburb like '%$strInputSuburb%' and street1 like '%$strInputStreet%'
                      order by Fines($) acs";***// After adding this line, it always said: Problem Query***

        $result1 = mysqli_query($conn, $querySql1)
            or die ("Problem Query...");.***// when I delete die function, it said cannot find the parameters.***
        $count = mysqli_num_rows($result1);
        if(!count==0){
            echo "<div class='table-responsive row' id='tableTop'>";
            echo "<div class='col-md-10 col-md-offset-1'>";
            echo "<table class='table table-bordered table-hover '>";
            echo "<tr><th>Location</th><th>Suburb</th><th>No. of Infringements</th><th>Fines($)</th></tr>";
            while($Row = mysqli_fetch_row($result1)){
                echo "<tr><td>Intersection of ".$Row[1]." and ".$Row[2]."</td><td>".$Row[3]."</td><td>".$Row[4]."</td><td>".$Row[5]."</td></tr>";
            }
            echo "</table>";
            echo "</div>";
            echo "</div>";
        }
        else {
            echo "No data found! Please search again!";
        }
        mysqli_free_result($result1);
        mysqli_close($conn);
    }
    else {
        echo "<div style='padding-top:9px;color:grey' class='col-md-3 col-md-offset-2'>";
        echo "Please type any <b>Suburb</b> or <b>Street</b>.";
        echo "</div>";
    }   

}
?> 
  • 写回答

1条回答 默认 最新

  • duan1979768678 2015-08-26 01:40
    关注

    fix the: 'order by Fines($) acs' to 'order by Fines ASC'

    and here is the code part (copy-paste it to needed line):

    $querySql1 = "select * from Infringement where 
                 suburb like '%".mysqli_real_escape_string($conn, $strInputSuburb)."%' and 
                 street1 like '%".mysqli_real_escape_string($conn, $strInputStreet)."%'
                 order by Fines ASC";
    
    $result1 = mysqli_query($conn, $querySql1) or die ("Problem Query...");
    if(mysqli_num_rows($result1)>0){
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊