PHP try/catch and fatal error

前端 未结 6 1855
庸人自扰
庸人自扰 2020-12-10 01:01

I\'m using the following script to use a database using PHP:

try{
    $db = new PDO(\'mysql:host=\'.$host.\';port=\'.$port.\';dbname=\'.$db, $user, $pass, $o         


        
6条回答
  •  半阙折子戏
    2020-12-10 01:40

    try{
    if(!is_null($db))
    {
        $query = $db->prepare("INSERT INTO users (...) VALUES (...);");
        $query->execute(array(
            '...' => $...,
            '...' => $...
        ));
    }
    }
    catch(Exception $e){
        $GLOBALS['errors'][] = $e;
    }
    

提交回复
热议问题