include files...
Hi everyone. I have the following code stored in a file called
"dbConnect.php".
I include it in a number of .PHP files (at the top of the file) with the
line -- include ('dbConnect.php');
I also close the connection at the bottom of the file.
For some reason it doesn't seem to connect. I try to SELECT items from
the database, but it doesn't return anything. However, if I just
cut-and-paste the contents of the file into the top of the page, it
works fine. Am I doing something wrong?
# dbConnect.php
$hostname = "localhost";
$dbuser = "root";
$dbpassword = "myPass";
$dbname = "cert";
$con = mysql_connect("$hostname","$dbuser","$dbpassword") ;
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$dbname", $con);
|