php mysqli_fetch_array()要求参数1为mysqli_result,布尔值在[duplicate]中给出

xyhw6mcr  于 2023-01-04  发布在  PHP
关注(0)|答案(1)|浏览(254)
    • 此问题在此处已有答案**:

What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such(1个答案)
九年前就关门了。
我在检查Facebook的User_id是否已经存在于我的数据库中时遇到了一些麻烦(如果不存在,它应该接受该用户为新用户,否则就加载画布应用程序)。我在我的托管服务器上运行它,没有问题,但在我的本地主机上,它给了我以下错误:
mysqli_fetch_array()要求参数1为mysqli_result,布尔值在
下面是我的代码:

<?
$fb_id = $user_profile['id'];
$locale = $user_profile['locale'];

if ($locale == "nl_NL") {
    // Checking User Data @ WT-Database
    $check1_task = "SELECT * FROM `users` WHERE `fb_id` = " . $fb_id . " LIMIT 0, 30 ";
    $check1_res = mysqli_query($con, $check1_task);
    $checken2 = mysqli_fetch_array($check1_res);
    print $checken2;
    // If the user does not exist @ WT-Database -> insert
    if (!($checken2)) {
        $add = "INSERT INTO users (fb_id, full_name, first_name, last_name, email) VALUES ('$fb_id', '$full_name', '$first_name', '$last_name', '$email')";
        mysqli_query($con, $add);
    }
    // Double-check, the user won't be able to load the app on failure inserting to the database
    if (!($checken2)) {
        echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
        exit;
    }
} else {
    include ('sorrylocale.html');
    exit;
}

我已经读到它与我的查询是错误的,但它已经对我的主机提供商工作,所以不可能是它!

vddsk6oq

vddsk6oq1#

mysqli_query()的查询失败,返回false
将其放在mysqli_query()之后,以查看发生了什么。

if (!$check1_res) {
    trigger_error(mysqli_error($con),E_USER_ERROR);
}

如需了解更多信息:
http://www.php.net/manual/en/mysqli.error.php

相关问题