gpt4 book ai didi

PHP - mysql_numrows() 期望参数 1 是资源, bool 值给出

转载 作者:行者123 更新时间:2023-11-29 13:23:36 25 4
gpt4 key购买 nike

我是新来的(也使用 PHP :D),我正在尝试安装彩票脚本,但出现此错误:

Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in /home/u289308161/public_html/lottery/get_lottery.php on line 7 Table 'u289308161_lot.lottery' doesn't exist

u289308161_lot 是数据库名称和使用它的用户。

get_lottery.php 文件是:

    <?php
require 'connect.php';

$query="SELECT * FROM lottery ORDER BY lottery_id DESC LIMIT 10";
$result=mysql_query($query);

$num=mysql_numrows($result);

?>

请帮忙!

最佳答案

这意味着 num_rows() 无法返回结果,因为查询失败。您始终需要知道查询是否失败:

<?php
require 'connect.php';

$query = "SELECT * FROM lottery ORDER BY lottery_id DESC LIMIT 10";
$result =mysql_query($query);

if($result == false)
{
echo 'The query failed.';
exit();
}

$num = mysql_num_rows($result);

?>

关于PHP - mysql_numrows() 期望参数 1 是资源, bool 值给出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20442516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com