Re: Can't Connect Within Function?!

From: Date: Mon, 01 Sep 2003 19:44:28 +0000
Subject: Re: Can't Connect Within Function?!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161383@lists.php.net to get a copy of this message
add this in the 1st line of the body of the function: global $shs_MySQLServer; global $shs_MySQLUser; global $shs_MySQLPassword; On Mon, 2003-09-01 at 14:20, Seth Willits wrote: > If I try to connect to a database within a function, I get the > following error. Why is this? > > > MySQL Connect Error : Can't connect to local MySQL server through > socket '/Private/tmp/mysql.sock' (2) > > function getUserPermissions() { > if ($_SESSION['permissions'] == '') { > // Connecting, selecting database > $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser, > $shs_MySQLPassword) > or die("MySQL Connect Error : " . mysql_error()); > > etc.... > } > } > > > Seth Willits > ------------------------------------------------------------------------ > --- > President and Head Developer of Freak Software - > http://www.freaksw.com > Q&A Columnist for REALbasic Developer Magazine - > http://www.rbdeveloper.com > Webmaster for REALbasic Game Central - > http://www.freaksw.com/rbgames > > "When purchasing that gift for your Special Someone guys remember, girls > like cute things. If it makes you want to puke, your chick will totally > love it." > -- Someone else out There > ------------------------------------------------------------------------ > ---

« previous php.general (#161383) next »