dtxzwdl08169 2019-06-10 17:48 采纳率: 0%
浏览 70

PHP 7:意外死亡,没有错误消息

I have what it must be a very simple method, but it's unexpectedly diying at 'return' line and not throwing any errors. I already enabled error reporting E_All; I already checked apache error_log;

What am I missing?

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;
    }
}
  • 写回答

1条回答 默认 最新

  • dtn43447 2019-06-10 18:57
    关注

    As @Dharman point me out: the error was due to be echoing unscaped utf8 chars.

    It was solved adding this right after the mysql connection:

    $db->set_charset('utf8mb4');
    

    He also provided a link to read more about it: UTF-8 all the way through

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码