When I try to make a new instance of a MySQLi object to connect to a local database, I get the following error:
Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /opt/lampp/htdocs/login_system/php/dbconnect.php on line 9
Here is the code for my file:
<?php
//Database credentials
$server = 'localhost';
$username = 'root';
$password = 'root'; //NOT secure, used this as a demo
$database = 'login';
//Create the database object
$db = new mysqli($server, $username, $password, $database);
//Was there errors?
if($db->connect_errno > 0)
{
die("Error connecting to database " . $database + "\nErrors: " + $db->connect_error);
}
?>
Any ideas as to why this is happening?