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?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php