【发布时间】:2018-11-06 00:08:46
【问题描述】:
我无法收到警告 sql 查询正在运行,mysqli_query() 返回 1,并且每次我的数据库也在更新。有什么问题?
警告:mysqli_num_rows() 期望参数 1 为 mysqli_result,布尔值在 C:\xampp\htdocs\qq\index.php 第 55 行给出
代码是
<?php
try{
$host="localhost";
$user="deb";
$password="12345";
$database="1";
$conn=mysqli_connect($host,$user,$password,$database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "connected succesfully";
}catch(Exception $e){
echo $e->getMessage();
}
$select=mysqli_select_db($conn,$database);
if($select)
{
echo "yipee";
}
echo "<table>
<thead>
<tr>
<th>Id</th>
<th>Value</th>
<th>Threshold Value</th>
<th>Chances of Fire</th>
</tr>
</thead>";
$val=$_GET["val"];
错误出现在这段代码中:
$tval=$_GET["tval"];
if ($val<$tval) {
$res="less ";
}
else{$res="exreme ";}
$sql1="INSERT INTO sensor (val,tval,result) VALUES
('".$val."','".$tval."','".$res."')";
$que=mysqli_query($conn,$sql1);
if($que)
{
if(mysqli_num_rows($que))
{
while ($data=mysqli_fetch_array($que))
{
echo "<tr>";
echo "<td>".$data['id']."</td><td>".$data['val']."/td>
<td>".$data['tval']."</td><td>".$data['result']."</td>";
echo"</tr>";
}
}
else{
echo "nooooooo";
}
}
echo"</table>"
? >
即使我要删除 mysqli_num_rows,它的显示错误也会出现
【问题讨论】: