View Single Post
 
Old September 27th, 2007, 02:32 PM
crmpicco crmpicco is offline
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default setup database connection include file in PHP

Code:
<?php 
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'mypassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'crmpicco_mini';
mysql_select_db($dbname);
?>
Is there a way I can have all of this in a database include file at the top of all my scripts? When i try it it just errors. Can only some of it go in an include?

I tried:

Code:
<?php include("/mini/inc/db_conn.php"); ?>
It didn't like that, or splitting the code into two seperate files as one site had suggested. Incidentally, do I always need to use "<?php" can't I just have "<?" to open scripting tags?

Cheers in advance,
Picco

www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk