Ask a Question related to PHP Development, Design and Development.
-
Seth Willits #1
Can't Connect Within Function?!
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 - [url]http://www.freaksw.com[/url]
Q&A Columnist for REALbasic Developer Magazine -
[url]http://www.rbdeveloper.com[/url]
Webmaster for REALbasic Game Central - [url]http://www.freaksw.com/rbgames[/url]
"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
------------------------------------------------------------------------
---
Seth Willits Guest
-
A function to connect lines (paths) that endpoints are near each other?
I am pretty sure I read this in the manual somewhere, but is there a function to connect lines (paths) that endpoints are near each other? I have... -
[PHP] Can't Connect Within Function?!
On Monday, September 1, 2003, at 11:33 AM, Mike Morton wrote: Ohh, I didn't even think of that. Thanks. Seth Willits... -
note 33988 added to function.mssql-connect
Using MSSQL 2000 and Windows Server 2003 Enterprise running on a separate machine from the web server, I was unable to get PHP to connect to MSSQL... -
note 33678 added to function.mysql-connect
Çäåñü âû íàéäåòå êó÷ó ïîëåçíîãî ìàòåðèàëà , ïîñåòèòå ãàëåðåþ 3D ðàáîò äðóãèõ äèçàéíåðîâ, ÑÊÀ×ÀÒÜ ÃÎÒÎÂÓÞ ÐÀÁÎÒÓ èëè çàäàòü ñâîé âîïðîñ íà... -
note 33624 added to function.mssql-connect
Just a little comment that I would like to add: If you intend to access MS SQL server remotely, you need to install SQL Server Client Tools on the... -
Mike Morton #2
Re: [PHP] Can't Connect Within Function?!
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" <seth@freaksw.com> 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 - [url]http://www.freaksw.com[/url]
> Q&A Columnist for REALbasic Developer Magazine -
> [url]http://www.rbdeveloper.com[/url]
> Webmaster for REALbasic Game Central - [url]http://www.freaksw.com/rbgames[/url]
>
> "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]mike@webtraxx.com[/email]
*
************************************************** **
"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
Mike Morton Guest
-
Curt Zirzow #3
Re: [PHP] Can't Connect Within Function?!
* Thus wrote Seth Willits (seth@freaksw.com):
Youre $shs_ vars are not defined here.> 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)
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt Zirzow Guest
-
Dan Anderson #4
Re: [PHP] Can't Connect Within Function?!
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 - [url]http://www.freaksw.com[/url]
> Q&A Columnist for REALbasic Developer Magazine -
> [url]http://www.rbdeveloper.com[/url]
> Webmaster for REALbasic Game Central - [url]http://www.freaksw.com/rbgames[/url]
>
> "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
> ------------------------------------------------------------------------
> ---Dan Anderson Guest



Reply With Quote

