PHP Includes file for connection

Permabanned
Joined
22 Apr 2007
Posts
1,805
Now, I all know you are being patient with me (most of the time :p) and I have this one simple question to ask (I think).

Some of my web pages appear to have multiple connections to the DB in them.

I have seen some PHP examples which call a file at the start

Code:
<?php
include 'somefile.html';
?>

can I have my connection details in here?

If so, can it be a PHP file?

for example, create a file called connect.php and do this

Code:
<?php
include 'connect.php';

//code
?>

and connect.php has this in it

Code:
mysql_connect('localhost', 'root', '');
mysql_select_db('db_name');

Is that how it works?
 
Back
Top Bottom