duanhong8839 2018-10-26 06:35
浏览 144

警告:mysqli_fetch_array()要求参数1为mysqli_result,第41行的C:\ xampp \ htdocs \ kurinchi \ kkmalar.php中给出布尔值

I cannot find out what's wrong in this code. Since the query executes and insert also works but the error msg shows:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\kurinchi\kkmalar.php on line 41

$q = intval($_GET['q']);
$availability = isset($_GET['availability']);
$con = mysqli_connect('localhost','root','','kurinchi');

if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"ajax_demo");
$sql="UPDATE rooms SET availability=(availability-1) WHERE ID = (SELECT ID from (SELECT * from rooms WHERE ID = '".$q."')AS innerResult)" ;
$result = mysqli_query($con,$sql);

if($result === FALSE) { 
    die(mysql_error()); 
}

echo "<table>
<tr>
    <th>ROOM TYPE</th>
    <th>AC TYPE</th>
    <th>PRICE</th>
    <th>AVAILABILITY</th>
    <th>BOOK </th>
</tr>";

while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['room_type'] . "</td>";
    echo "<td>" . $row['ac_type'] . "</td>";
    echo "<td>" . $row['price'] . "</td>";
    echo "<td>" . $row['availability'] . "</td>";
    echo "<td>" . $row['booking_status'] . "</td>";
    echo "</tr>";
}

echo "</table>";
mysqli_close($con);
  • 写回答

1条回答 默认 最新

  • dongruolin5324 2018-10-26 06:46
    关注

    Try this after mysqli_query()

    if (!$result) {
        printf("Error: %s
    ", mysqli_error($con));
        exit();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM