gpt4 book ai didi

php - mysqli_fetch_array() 期望参数 1 为 mysqli_result, boolean 值

转载 作者:IT老高 更新时间:2023-10-28 12:59:46 25 4
gpt4 key购买 nike

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

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

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

最佳答案

mysqli_query() 的查询失败并返回 false

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

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

更多信息:

http://www.php.net/manual/en/mysqli.error.php

关于php - mysqli_fetch_array() 期望参数 1 为 mysqli_result, boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15439919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com