As you can probably tell i am novice to this and trying to make life a little easier for my self by creating a config file with all the settings of my site.
i am doing this as i am learning and trying to push my knowledge that little bit harder and repeating the same code over and over again
i have created a file named settings.php and the code i have at current is this
<?php
return array(
'host' => 'localhost',
'username' => 'me',
'password' => 'password',
'db_name' => 'mydb'
);
?>
and in my page i have put the following code
<?php
//set connection variables
$host = include('settings.php');
$username = include('settings.php');
$password = include('settings.php');
$db_name = include('settings.php');
//connect to mysql server
$mysqli = new mysqli($host, $username, $password, $db_name);
//check if any connection error was encountered
if(mysqli_connect_errno()) {
echo "Error: Could not connect to database.";
exit;
}
?>
I got this code from another question that can be found here
This seams not to work but i cant be sure as it doesn't give a error.
Before i continue with this i am wanting to add other settings which will be stored in the database is this the best way for me to do this?