gpt4 book ai didi

php - PHP 7 : Dying unexpectedly without error message

转载 作者:行者123 更新时间:2023-12-03 08:45:09 26 4
gpt4 key购买 nike

我知道它必须是一个非常简单的方法,但是它出乎意料地在“返回”行干掉并且没有引发任何错误。我已经启用了错误报告E_All;我已经检查了Apache error_log;

我想念什么?

public function get_by_state_id(int $state_id){
$db = new mysqli('localhost', 'root', '', 'foo');
$query = "
SELECT *
FROM {$this->table}
WHERE state_id = ?
ORDER BY name";
if($stmt = $db->prepare($query)){
$stmt->bind_param('i',$state_id);
$stmt->execute();
$res = $stmt->get_result();

$rows = [];

while($obj = $res->fetch_object()){
$rows[] = $obj;
}

return $rows;
}
}

最佳答案

正如@Dharman指出的那样:错误是由于回显未转义的utf8字符。

解决了在mysql连接后添加以下内容的问题:

$db->set_charset('utf8mb4');

他还提供了一个链接,以了解更多信息: UTF-8 all the way through

关于php - PHP 7 : Dying unexpectedly without error message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56531177/

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