mysqli_fetch_array() 期望参数 1 为 mysqli_result,布尔值

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

问题描述

我在检查我的数据库中是否已经存在 Facebook User_id 时遇到了一些麻烦(如果不存在,则它应该接受该用户作为新用户,否则只需加载画布应用程序).我在托管服务器上运行它并没有问题,但在我的本地主机上它给了我以下错误:

I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). 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() 期望参数 1 是 mysqli_result,布尔值在

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 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;
}

我读到这与我的查询错误有关,但它已在我的托管服务提供商上运行,所以不可能!

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() 的查询失败并返回 false.

The query given to mysqli_query() is failing and returning false.

把它放在 mysqli_query() 之后看看发生了什么.

Put this after mysqli_query() to see what's going on.

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

更多信息:

http://www.php.net/manual/en/mysqli.错误.php

这篇关于mysqli_fetch_array() 期望参数 1 为 mysqli_result,布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)