How to connect to another database in my site more easily?

I have many different files for my website and a database I am connected to. When I want to perform some changes in the files or in make some tests, I change the connection it to another database on my localhost, by changing manually in every file.

I imagine that there is an easier method to make this process easier and faster.

Does it really exist?

The information about my localhost database:

$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = 'phplogin';

The information about my website database:

$DATABASE_HOST = 'sql108.epizy.com';
$DATABASE_USER = 'epiz_26325823';
$DATABASE_PASS = '*******';
$DATABASE_NAME = 'epiz_26325823_phplogin2';

Upvotes: 1

Views: 51

Answers (1)

Mureinik
Mureinik

Reputation: 311028

You shouldn't store the connection information more than once. Store it in a single config.php file, and require it in all the files that need it.

Upvotes: 2

Related Questions