What are best practices for initializing MySQL support in PHP when using Apache as a module?
When initializing MySQL support in PHP when using Apache as a module, it is best practice to use the mysqli extension instead of the deprecated mysql extension for improved security and functionality. You should also ensure that the necessary MySQL settings are configured in your php.ini file.
<?php
// Connect to MySQL using mysqli extension
$mysqli = new mysqli("localhost", "username", "password", "database");
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully";
?>