Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP MYSQL Connection

Status
Not open for further replies.

bobrivers2003

Technical User
Oct 28, 2005
96
GB
I use the following to connect to a mysql database:

mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

The trouble is I have about 20 pages that connect to the server and changing any details will be a pain the the arse.

Is there a function in php to include text from a separate file that would for example have the connection settings so I would only have to change one file and not 20?
 
put the calls into a file called "db.php"
and then at the start of each page use the call

Code:
require_once ("db.ph");

 
That is excellent stuff. Makes life alot easier now.

Thank you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top