【发布时间】:2014-05-06 00:38:48
【问题描述】:
每次运行此 php.ini 时,我都会遇到相同的 3 个错误。我不知道我做错了什么,有人可以帮忙吗?
以下是错误:
[2014 年 5 月 5 日 19:20:50 America/Chicago] PHP 警告:mysqli_query() 预计至少有 2 个参数,其中 1 个在 /home/sagginev/public_html/Nutrifitness/search.php 在第 10 行
[2014 年 5 月 5 日 19:20:50 America/Chicago] PHP 警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,在 /home/sagginev/public_html/Nutrifitness/search.php 在第 11 行
[2014 年 5 月 5 日 19:20:50 America/Chicago] PHP 警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,在 /home/sagginev/public_html/Nutrifitness/search.php 第 16 行
这是我的代码
enter code here
<?php
$con=mysqli_connect('localhost','sagginev_rob','122989','sagginev_Nutrifitness');
if (mysqli_connect_errno()) // Check connection
{ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
if(!isset($_POST['search'])) {
header("Location:home.php");
}
$search_sql="Select * FROM Questions WHERE username LIKE '%".$_POST['search']."%' OR feedback LIKE '%".$_POST['search']."%'";
$search_query=mysqli_query($search_sql);
if(mysqli_num_rows($search_query)!=0) {
$search_rs=mysqli_fetch_assoc($search_query);
}
?>
<H2> Search Results</H2>
<?php if(mysqli_num_rows($search_query)!=0) {
do { ?>
<p><?php echo $search_rs['name']; ?> </p>
<?php } while ($search_rs=mysqli_fetch_assoc($search_query));
} else {
echo "No results found";
} ?>
<form>
<br>
<input type="button" value="Go Back Home" onClick="parent.location='http://sagginevo.com/Nutrifitness/home.php'">
</form>
【问题讨论】:
-
您应该先查看手册。
-
...今晚似乎是一种趋势。
-
与您的问题没有任何联系 - 使用
header("location...");重定向后,您应该添加exit或die调用以防止执行其余代码