You need to read up on the scope of variables within functions.

You should have something like:

function 
getUserPermissions($shs_MySQLServer,$shsMySQLUser,$shs_MySQLPassword) {
 if ($_SESSION['permissions'] == '') {
 // Connecting, selecting database
 $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser,
 $shs_MySQLPassword)
 or die("MySQL Connect Error : " . mysql_error());
 
 etc....
 }
}

And call it with:
GetUserPermissions("server","user","password") where server,user and
password are the variables that contain those values.


On 9/1/03 2:20 PM, "Seth Willits" <[EMAIL PROTECTED]> 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
> ------------------------------------------------------------------------
> ---

--
Cheers

Mike Morton

****************************************************
*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*
****************************************************

"Indeed, it would not be an exaggeration to describe the history of the
computer industry for the past decade as a massive effort to keep up with
Apple."
- Byte Magazine

Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
-- NullGrey 

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

Reply via email to