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 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探