Page 1 of 1
Is this a valid PHP function call?
Posted: Sun Mar 14, 2004 4:57 am
by LonelyProgrammer
Code: Select all
function connectToDB(&$errorMessage = "" )
{
$link = mysql_connect( ... )
if (! $link) $errorMessage = "Failed to connect to mysql";
}
connectToDB();
Posted: Sun Mar 14, 2004 5:14 am
by LonelyProgrammer
Gah, I stupidly post in the wrong forum. Can someone help to move the post? Apologies in advance!
Posted: Sun Mar 14, 2004 7:25 pm
by Black Unicorn
I'd only make one modification; Try instead of
...
if ($link) $errorMessage = "Failed";
...
Something like this:
if (!$link) return false;
else return true;
This way, you could do something like this:
$x = connectToDB();
if (!$x){echo("Failed! Help!");}
Best of coding,
Rage