doudeng3008 2017-07-24 11:18
浏览 36

更改代码并修复它?

I know that I'm using multiple PHP styles, but I don't know how can I set this.

I think that there something wrong in exit(); and I don't know what to do to get the desired result.

<?php
    $mysqli = new mysqli("localhost", "root", "", "search");
       if(isset($_GET['search_button']))
            {
                $search = $_GET['search'];
                    if(search=="")
             {
                echo "<center> <b> Please write something in Search Box </b> </center>"

                exit();
             }

                $sql = "select * from website where site_key like '%$search%' limit 0, 5";

                $rs =  mysql_query($sql);

                 if(mysql_num_rows($rs)<1)
                {
                 echo "<center> <h4> <b> Oops !!! Sorry, there is no result found to related the word. </b> </h4> </center>";
                 exit();
                 }

                echo "<font size='+1' color='#1a1aff'> images for $search</font>";

                 while($row = mysql_fetch_array($rs))
                 {
                     echo   "<td>
                     <table style='margin-top: 10px'>
                        <tr>
                            <td>
                                <img src='img/$row[5]' height='100px'>
                            </td>
                         </tr>
                     </table>
                     </td>"
            }
            }
?>
  • 写回答

2条回答

  • dtyw10299 2017-07-24 11:28
    关注

    mysql_query($sql) should be mysqli_query($mysqli,$sql)

    (Connection parameter required for mysqli_query() )

    mysql_num_rows($rs) should be mysqli_num_rows($rs)

    mysql_fetch_array($rs) should be mysqli_fetch_array($rs)

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?