Re: A weird problem that probably has a comma in the wrong spot....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On May 16, 2010, at 1:11 PM, Ashley Sheridan wrote:

On Sun, 2010-05-16 at 13:14 -0400, Jason Pruim wrote:

Hi Everyone!

So I'm sitting here trying to get my RSS feed to work off of my main
database login script so that I can centralize the management of the
whole blasted thing, you know... stuff like only having the password
in one place to log into the DB :)

I can connect just fine if I include all the connection stuff locally
in my file, but when I try and include it so I don't have to reinvent
the wheel it says it can't connect.... Host, Username, & Password have
all been checked and doubled checked. And actually the database
connection script works just fine since I'm using it to pull the
content from my main page and that's working just fine...


Here's the code I'm using locally on the page:

<?PHP
$server = "localhost";
$username = "realusername";
$password = "realpass";
$database = "realdatabase";


$linkID = mysql_connect($server, $username, $password) or die("Could
not connect to host." . mysql_error());
mysql_select_db($database, $linkID) or die("Could not find
database." . mysql_error($linkID));
?>

That code works...

When I change it to:

<?PHP
$linkID = dbconnect($server, $username, $password, $database) or
die("Could not connect to host." . mysql_error());
?>


with that function defined as:

<?PHP
function dbconnect($server, $username, $password, $database) {
     mysql_connect($server, $username, $password) or die("Unable to
connect: ".mysql_error());

     mysql_select_db($database) or die("Unable to select
database:".mysql_error());


}
?>

that will not work on my rss feed. But it does work on my main page
which uses the dbconnect script. The only error that I'm getting is
the one set in my dbconnect call... "Could not connect to host".

So can anyone see where I'm missing my comma or semicolon? :)


Are the MySQL ports open and available on both servers?

Hey Ash,

Yes they are. It's on the same machine so ports shouldn't be an issue I would think?




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux