本文介绍了mysqli_fetch_array()期望参数1为mysqli_result,boolean给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果FB User_id已经存在于我的数据库(如果它不应该接受用户为新的,而只是加载画布应用程序),我有一些麻烦。我在我的主机服务器上运行它,没有问题,但是在我的本地主机上,它给我以下错误:

I'm have some trouble checking if an FB User_id already exists in my db (if it doesn't it should then accept user as a new one and else just load the canvas app). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error:

mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in

这是我的代码:

<?
$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 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, User won't be able to load app on failure inserting to database
    if (!($checken2)) {
        echo "Excuse us " . $first_name . ". Something went terribly wrong! Please try again later!";
        exit;
    }
} else {
    include ('sorrylocale.html');
    exit;
}

我已经阅读它与我的查询错误有关,但它已经在我的主机提供商上工作,所以不可能!

I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it!

推荐答案

该查询失败并返回

mysqli_query()之后放这个,看看发生了什么。

put this after mysqli_query() to see whats going on.

if (!$check1_res) {
    printf("Error: %s\n", mysqli_error($con));
    exit();
}

了解更多信息:

这篇关于mysqli_fetch_array()期望参数1为mysqli_result,boolean给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 08:29