I am trying to see if this code works so that no Fatal Error will come out. I am purposely trying to make it show an error. I don't have a database called "aaaa"
$conn = mysqli_connect("localhost", "root", "", "aaaa");
if($conn ->connect_error){
die("Connection Error");
}
But is something wrong here? Because it is not showing the message. I was trying to make the same result as this try/catch code here.
try{
$conn = mysqli_connect("localhost", "root", "", "aaaa");
}
catch (Exception $e){
die("Connection Error");
}
And this one is properly working. I am searching how to catch errors in Mysqli and the 1st code are the results that I get but somehow it is not working for me. Did I do something wrong? Because it throws Fatal Error instead of the message "Connection Error".