php mysqli_fetch_array() 期望参数 1 是 mysqli_result,布尔值在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15439919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
提问by Mats de Swart
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:
我在检查 Facebook User_id 是否已存在于我的数据库中时遇到了一些麻烦(如果不存在,则应接受该用户作为新用户,否则只需加载画布应用程序)。我在我的托管服务器上运行它并且没有问题,但是在我的本地主机上它给了我以下错误:
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
mysqli_fetch_array() 期望参数 1 是 mysqli_result,布尔值在
Here's my code:
这是我的代码:
<?
$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!
我读过它与我的查询错误有关,但它对我的托管服务提供商有效,所以不可能!
回答by castis
That query is failing and returning false.
该查询失败并返回false.
Put this after mysqli_query()to see what's going on.
把这个放在后面mysqli_query()看看发生了什么。
if (!$check1_res) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
For more information:
想要查询更多的信息:

