Hi:
I use a web host that runs:
PHP 4.3.10 with
MySQL 3.23.58 on
Apache 1.3.33
When I run a function to get values from the database through connecting then SELECT, it is successful. However, when I adjust the function to simply connect, it would appear not to be successful. And I’m stumped as to why. Script and output below …
~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?php
function db_connect()
{
$db = mysql_pconnect(“db:4000:/usr/bin/mysql”,”name”,”PW”);
if (!$db)
{
echo ‘Error: Could not connect to database. Please try again later.’;
return false;
exit;
}
// else ..
if (!mysql_select_db(“scizors”,$db));
return false;
if (mysql_select_db(“scizors”,$db));
return true;
}
// Function is used in script
$connected = db_connect();
echo “db_connect = “, $connected;
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<BR><BR>
<?php
if ($connected === true)
echo “Connected”;
if ($connected === false)
echo “Not connected”;
?>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The output:
db_connect =
Not connected
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So it would not seem to work. It’s got to be something simple. Any ideas?
Thanks guys.
tork