由于某种原因,我被过去一年对我来说很简单的事情卡住了。将数据插入数据库。今天,我一直在努力解决这个问题,我似乎无法理解为什么stmt->execute()
返回false?!我没有得到错误,即使我打开PHP和mysql错误。下面是我的代码:
else
{
// We are all good, lets enter this person into our DB
$CheckUser->close();
if ($insert_stmt = $mysqli->prepare("INSERT INTO users (name, email, country, region, city, address, password, salt) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) {
$insert_stmt->bind_param('ssssssss', $name, $email, $geoplugin->countryName, $geoplugin->regoin, $geoplugin->city, $address, $password, $random_salt);
if($insert_stmt->execute())
{
// Success, redirect the user to his page (Remember to login the user)
header("Location: dashboard.php");
}
else
{
// Something happened
echo "Something Happened";
}
}
}
在我的页面上,"发生了什么事"正在被回应。然而,如果我打开mysql错误,那么我只是得到一个空白页后,我提交。我做错了什么?
根据OP的要求,从我的评论中给出一个答案。
您可能在$geoplugin->regoin
中打错了字,并打算使用$geoplugin->region
?