p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Can't connect to MySQL through socket


Message #1 by "Lawrence" <lkrubner@g...> on Fri, 15 Feb 2002 02:10:50 -0500
 I'm calling this function and getting this error message. I don't

 understand what it means. The code is choking on the mysql_connect

 call (which is line 14 in my code, though not here).



Oddly, this same function was called earlier in the same session, and the code did not choke. I'm

wondering if the host machine is trying to keep me from opening too many connections?







 Warning: MySQL Connection Failed: Can't connect to local MySQL server

 through socket '/tmp/mysql.sock' (111) in lr_functionsFile.php on line

 14







 function connectLrToDb() {

 // this brings the database variables into the function

 global $host ;

 global $username ;

 global $passwordDb ;

 global $database ;

 // this connects to the server

 $result1 = mysql_connect ($host, $username, $passwordDb) or die

 (mysql_error());

 // this selects the correct database

 $result2 = mysql_select_db($database) or die (mysql_error());

 // uncomment the following lines if you need to debug

 // printf $result1 ;

 // printf $result2 ;

 return ;

 }







Message #2 by "sneax" <sneaker@p...> on Fri, 15 Feb 2002 11:17:28 +0100
coz there IS a server but it's not running



turn it on and it will work :)





----- Original Message -----

From: "Lawrence" <lkrubner@g...>

To: "beginning php" <beginning_php@p...>

Sent: Friday, February 15, 2002 8:10 AM

Subject: [beginning_php] Can't connect to MySQL through socket





> I'm calling this function and getting this error message. I don't

>  understand what it means. The code is choking on the mysql_connect

>  call (which is line 14 in my code, though not here).

>

> Oddly, this same function was called earlier in the same session, and the

code did not choke. I'm

> wondering if the host machine is trying to keep me from opening too many

connections?

>

>

>

>  Warning: MySQL Connection Failed: Can't connect to local MySQL server

>  through socket '/tmp/mysql.sock' (111) in lr_functionsFile.php on line

>  14

>

>

>

>  function connectLrToDb() {

>  // this brings the database variables into the function

>  global $host ;

>  global $username ;

>  global $passwordDb ;

>  global $database ;

>  // this connects to the server

>  $result1 = mysql_connect ($host, $username, $passwordDb) or die

>  (mysql_error());

>  // this selects the correct database

>  $result2 = mysql_select_db($database) or die (mysql_error());

>  // uncomment the following lines if you need to debug

>  // printf $result1 ;

>  // printf $result2 ;

>  return ;

>  }

>

>

>

>




$subst('Email.Unsub').

>



Message #3 by "Lawrence" <lkrubner@g...> on Fri, 15 Feb 2002 13:12:28 -0500

From: "sneax" <sneaker@p...>

> coz there IS a server but it's not running

> turn it on and it will work



Thanks, but this is on a website that's in a hosted environment, so I can't turn the server off or

on. From what you're saying I gather that the error message is simply saying "The server is down"?









Message #4 by "Lawrence" <lkrubner@g...> on Fri, 15 Feb 2002 13:34:36 -0500
I'm a complete idiot. I figured out what the problem was. The password, host, username, and db, were

all held in a config file. I was including the config file in one page but not another. When I

called the function from the page that didn't have the config info, of course it choked.









----- Original Message -----

From: "Lawrence" <lkrubner@g...>

To: "beginning php" <beginning_php@p...>

Sent: Friday, February 15, 2002 1:12 PM

Subject: [beginning_php] Re: Can't connect to MySQL through socket





>

> From: "sneax" <sneaker@p...>

> > coz there IS a server but it's not running

> > turn it on and it will work

>

> Thanks, but this is on a website that's in a hosted environment, so I can't turn the server off or

> on. From what you're saying I gather that the error message is simply saying "The server is down"?

>





Message #5 by "sneax" <sneaker@p...> on Fri, 15 Feb 2002 19:32:25 +0100
Probably yes



I had the same problem some time ago and it was because the server chrashed

and they restarted it but they forgot starting mysql - they only started

Apache.

So the server IS there but you can't connect to it because it's down.



Maybe a mail to your hosting provider can solve things?



greetz, sneax





----- Original Message -----

From: "Lawrence" <lkrubner@g...>

To: "beginning php" <beginning_php@p...>

Sent: Friday, February 15, 2002 7:12 PM

Subject: [beginning_php] Re: Can't connect to MySQL through socket





>

> From: "sneax" <sneaker@p...>

> > coz there IS a server but it's not running

> > turn it on and it will work

>

> Thanks, but this is on a website that's in a hosted environment, so I

can't turn the server off or

> on. From what you're saying I gather that the error message is simply

saying "The server is down"?

>

>

>

>

>




$subst('Email.Unsub').

>



Message #6 by "sneax" <sneaker@p...> on Fri, 15 Feb 2002 20:00:25 +0100
I'm glad you found out :)



Greetz, sneax





----- Original Message -----

From: "Lawrence" <lkrubner@g...>

To: "beginning php" <beginning_php@p...>

Sent: Friday, February 15, 2002 7:34 PM

Subject: [beginning_php] Re: Can't connect to MySQL through socket





> I'm a complete idiot. I figured out what the problem was. The password,

host, username, and db, were

> all held in a config file. I was including the config file in one page but

not another. When I

> called the function from the page that didn't have the config info, of

course it choked.

>

>

>

>

> ----- Original Message -----

> From: "Lawrence" <lkrubner@g...>

> To: "beginning php" <beginning_php@p...>

> Sent: Friday, February 15, 2002 1:12 PM

> Subject: [beginning_php] Re: Can't connect to MySQL through socket

>

>

> >

> > From: "sneax" <sneaker@p...>

> > > coz there IS a server but it's not running

> > > turn it on and it will work

> >

> > Thanks, but this is on a website that's in a hosted environment, so I

can't turn the server off or

> > on. From what you're saying I gather that the error message is simply

saying "The server is down"?

> >

>

>

>




$subst('Email.Unsub').

>




  Return to Index