【发布时间】:2017-07-24 11:18:45
【问题描述】:
我知道我正在使用多种 PHP 样式,但我不知道如何设置。
我认为exit() 有问题;我不知道该怎么做才能得到想要的结果。
<?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>"
}
}
?>
【问题讨论】:
-
你好。您将
mysqli和mysql混为一谈——这是行不通的。请停止使用mysql_*驱动程序,它已过时且不再受 PHP7 支持。仅使用mysqli_*,然后您的代码将起作用。只需调整您的查询,哦,顺便说一句,看看bobby-tables.com 并了解一些有关 SQL 注入的知识。使用此代码,您的数据库可以在几秒钟内被黑客入侵,而无需深入了解数据库.. 只需 SQL 注入就可以完美地处理这个问题。 -
echo "<center> <b> Please write something in Search Box </b> </center>"最后错过了;。 -
洛科怎么说,你的回声线有错误..
标签: php