Database problem - works in Windows - not Linux
| From: | Lee P. Reilly | Date: | Wed, 12 Feb 2003 22:29:56 +0000 |
| Subject: | Database problem - works in Windows - not Linux | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135374@lists.php.net to get a copy of this message | ||
Hi there,
I'm moving an application from Windows -> Linux, and am having a problem
with the database. I have the following script to test my database
connection (Linux):
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$connection = mysql_connect("localhost","","") or die
("Couldn't
connect.");
$dbs = mysql_list_dbs($connection) or die("Couldn't list databases.");
$db_list = "<ul>";
$i = 0;
while ($i < mysql_num_rows($dbs))
{
$db_names[$i] = mysql_tablename($dbs,$i);
$db_list .= "<li>$db_names[$i]</li>";
$i++;
}
$db_list .= "</ul>";
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This works fine and displays:
* mysql
* sasdap
* test
* testDB
However, the code that I developed under Windows doesn't work in Linux:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function db_connect()
{
// the connection string (host, user, password)
$result = mysql_pconnect("localhost", "", "");
if (!$result)
return false;
if (!mysql_select_db("sasdap"))
return false; // false is returned!
return $result;
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Which is called like so:
// connect to db
$conn = db_connect();
if (!$conn)
return 0;
Any thoughts on why this is happening?