mysqli_fetch_array()预计参数1被mysqli_result,布尔在给定的 [英] mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
问题描述
我有一些麻烦检查如果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
下面是我的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 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!
推荐答案
您查询失败并返回一个假
值。
Your query is failing and returning a false
value.
把这个你的 mysqli_query后()
来看看怎么回事。
put this after your mysqli_query()
to see whats going on.
if (!$check1_res) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
了解更多信息。
<一个href=\"http://www.php.net/manual/en/mysqli.error.php\">http://www.php.net/manual/en/mysqli.error.php
这篇关于mysqli_fetch_array()预计参数1被mysqli_result,布尔在给定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!