some who doesn’t know what they’re doing here. I am trying to connect to a MySQL database with mysqli from a PHP site running on a local Apache server with PHP 8.3.7, but even when I supply the wrong credentials mysqli is not throwing an exception (not showing on website).
echo nl2br("Hellolrd n");
echo "TEST 123456789";
$servername_mysql = "localhost";
$port_mysql = 3306;
$username_mysql = "user1";
$password_mysql = 1234;
$database_mysql = "db1";
$charset = "utf8mb4";
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$db = new mysqli($servername_mysql, $username_mysql, $password_mysql, $database_mysql, $port_mysql);
$db->set_charset($charset);
$db->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
} catch (mysqli_sql_exception $e) {
throw new mysqli_sql_exception($e->getMessage(), $e->getCode());
}
unset($servername_mysql, $port_mysql, $username_mysql, $password_mysql, $database_mysql, $charset);
screenshot of website
I have tried to display host_info with echo, but that also showed nothing. I know that the database is live and working as I managed to connect to it with the MySQL shell on windows and use some commands. The top two lines are showing so my PHP interpreter is working fine. I am following this guide. I am going kinda insane here, hopefully somebody here can help me. Thanks in advance.
Akronos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.