我正在尝试用 MySQLi 替换我的 MySQL,我得到了结果 - 没关系,但是当涉及到更新 MySQL 时,我的代码失败了(我只更新了 MySQL 部分)
inc_mysql_connect.php
$db = mysqli_connect($host, $user, $pass, $dbase) or die ();
inc_global_functions.php
if($_POST['costAlertTrue'] != "") {
// CHECKS AND IF ERROR - REDIRECT BACK
if(..) {$_SESSION['status'] ="E1"; header("Location: ./?page=cAlert"); exit();}
if(..) ...
// SQL
$sql = "UPDATE ".$dbprfx."_users SET costAlertVar = ? WHERE connection = ?";
$eintrag = $db->prepare($sql);
if ($eintrag->error()) { print($eintrag->error()); }
$eintrag->bind_param('ss',$costAlertVar,$userConnection);
$eintrag->execute();
$eintrag->close();
// REDIRECT
$_SESSION['status'] ="on"; header("Location: ./?page=cAlert");
} // End
有人能找出这段代码中的错误吗?
注意事项
if($_POST['costAlertTrue'] != "") {
die('XX'); exit('XX');
}
好像die();导出();或任何其他错误在 if 子句中不起作用
最佳答案
行 $eintrag->error(); {die('Not Working');}
每次都会死掉,即使一切都很好,因为 PHP 会看到语句 $eintrag->error()
和代码块 {die('不工作');}
.
你应该这样使用:
if (!$eintrag->error()) { die('Not Working'); }
关于php - MySQLi更新和死亡();和退出();不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20401810/