This basic commands:
new mysqli($servername, $username, $password);
mysqli_connect($servername, $username, $password);
are blocked in PHP 8.2+ with Uncaught Error: Class "mysqli" not found
or Uncaught Error: Call to undefined function mysqli_connect()
(depends on which one you used) seemingly due to PHP 8.2: MySQLi can no longer be compiled with libmysqli (which suggests to use the mysqlnd
library instead of the libmysql
library).
The way to bypass it in cPanel, as explained here (and in a past version here), is to check the usually turned off nd_mysqli
, since obviously having mysqlnd
(which is checked by default) is not enough.
But since my hosting explained "the reason why the "nd_mysqli" was disabled is because the module is not recommended", is there another PHP command that is recommended for PHP 8.2+ to connect to a MySQL database from PHP that will not trigger any errors or require any special setup?