I'm trying to show a message when a fatal error occurs after executing a query to a mysql database. I want to do smthg like that:
$query="INSERT INTO ...";
$stmt=$dbc->prepare($query);
$stmt->bind_param("sdd", $place,$id_user,$id_sem);
$success=$stmt->execute();
if($success)
echo "success";
else
echo "error";
The problem is that because a fatal error occurs, my program logically crashes, so I can't print nothing just after the line with the execute() function.
I tried to solve this problem with a try/catch statement, but there's no change.
$query="INSERT INTO ...";
try{
$stmt=$dbc->prepare($query);
$stmt->bind_param("sdd", $place,$id_user,$id_sem);
$success=$stmt->execute();
}
catch(Throwable $e){
echo "error";
}
Can someone help me please ?
Thanks !