I have a site I've been working on for a couple months locally, and finally uploaded it today. There is 1 single file that I use as an "include" that wont read the database for some reason. I'm using this "db.php" file to connect to the database:
<?php
// db.php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
function dbConnect($db='') {
global $dbhost, $dbuser, $dbpass;
$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die('The site database appears to be down.');
if ($db!='' and !@mysql_select_db($db))
die('The site database is unavailable.');
return $dbcnx;
}
?>
I then use this to connect to the DB:
dbConnect['xs'];
I have a file named "cities.php" that reads from the database, then displays the needed cities for that state. Here is the part of the file that its hanging on.
<?php
include("cat.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<table width="100%" border="0" cellpadding="2" cellspacing="2" align="left">
<tr>
<td valign="top" width="50%">
<?php
echo "first,";
include("includes/db.php");
echo "dbincluded,";
dbConnect("xs");
echo "dbconnected,";
$st=$_GET['st'];
$query = "SELECT city, st FROM cities WHERE st='$st' ORDER BY city";
echo "last";
The program is hanging up and actually stopping. The only output I get is:
first,dbincluded
Which obviously means its hanging up on "dbConnect("xs");". But I'm using this code in multiple places in the program, and it is working fine. This file is the only one giving problems. The funny thing is that this program works fine locally, just not when I upload to my server. Anybody see anything I'm not seeing? Thanks for any help.