PHP mysql_connect randomly failing

PHP mysql_connect randomly failing

am 19.08.2003 23:36:15 von jsd

I've got a library of PHP code whose first line is a mysql_connect
statement, like this:

$dbh=mysql_connect() or die("mysql connect failed: $php_errmsg");

Approximately 1% of the time it just fails, for no stated reason:

Warning: mysql_connect() [http://www.php.net/function.mysql-connect]:
in /var/httpd/htdocs/pi/pi.php on line 3
mysql connect failed:

Any ideas why this would be happening? PHP is version 4.3.1 (same
results with the latest 4.3.3 release candidate), Mysql is 4.0.12

thanks
-jsd-



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

RE: PHP mysql_connect randomly failing

am 20.08.2003 00:41:00 von Michael

Are you connecting through a TCP or a UNIX domain socket?

--Michael

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Jon Drukman
> Sent: Tuesday, August 19, 2003 2:36 PM
> To: mysql@lists.mysql.com
> Subject: PHP mysql_connect randomly failing
>
>
> I've got a library of PHP code whose first line is a mysql_connect
> statement, like this:
>
> $dbh=mysql_connect() or die("mysql connect failed: $php_errmsg");
>
> Approximately 1% of the time it just fails, for no stated reason:
>
> Warning: mysql_connect() [http://www.php.net/function.mysql-connect]:
> in /var/httpd/htdocs/pi/pi.php on line 3
> mysql connect failed:
>
> Any ideas why this would be happening? PHP is version 4.3.1 (same
> results with the latest 4.3.3 release candidate), Mysql is 4.0.12
>
> thanks
> -jsd-
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?> unsub=michael@dynamine.net
>
>


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 20.08.2003 03:45:06 von jsd

unix domain.

Michael S. Fischer wrote:
> Are you connecting through a TCP or a UNIX domain socket?
>
> --Michael
>
>
>>-----Original Message-----
>>From: news [mailto:news@sea.gmane.org] On Behalf Of Jon Drukman
>>Sent: Tuesday, August 19, 2003 2:36 PM
>>To: mysql@lists.mysql.com
>>Subject: PHP mysql_connect randomly failing
>>
>>
>>I've got a library of PHP code whose first line is a mysql_connect
>>statement, like this:
>>
>>$dbh=mysql_connect() or die("mysql connect failed: $php_errmsg");
>>
>>Approximately 1% of the time it just fails, for no stated reason:
>>
>>Warning: mysql_connect() [http://www.php.net/function.mysql-connect]:
>>in /var/httpd/htdocs/pi/pi.php on line 3
>>mysql connect failed:



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 20.08.2003 08:50:16 von Antony Dovgal

On Tue, 19 Aug 2003 14:36:15 -0700
Jon Drukman wrote:

> I've got a library of PHP code whose first line is a mysql_connect
> statement, like this:
>
> $dbh=mysql_connect() or die("mysql connect failed: $php_errmsg");
>
> Approximately 1% of the time it just fails, for no stated reason:
>
> Warning: mysql_connect() [http://www.php.net/function.mysql-connect]:
> in /var/httpd/htdocs/pi/pi.php on line 3
> mysql connect failed:
>
> Any ideas why this would be happening? PHP is version 4.3.1 (same
> results with the latest 4.3.3 release candidate), Mysql is 4.0.12
You should turn
track_errors = On
in your php.ini (default value is Off), if you want to see last PHP error in $php_errmsg variable.

But I suppose the best solution would be not to use $php_errmsg, but to use mysql_error() -
at least this function does not depend on configuration settings.


---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 21.08.2003 06:31:48 von jsd

Antony Dovgal wrote:

> On Tue, 19 Aug 2003 14:36:15 -0700
> Jon Drukman wrote:

>>Approximately 1% of the time it just fails, for no stated reason:
>>
>>Warning: mysql_connect() [http://www.php.net/function.mysql-connect]:
>>in /var/httpd/htdocs/pi/pi.php on line 3
>>mysql connect failed:
>>
>>Any ideas why this would be happening? PHP is version 4.3.1 (same
>>results with the latest 4.3.3 release candidate), Mysql is 4.0.12
>
> You should turn
> track_errors = On
> in your php.ini (default value is Off), if you want to see last PHP error in $php_errmsg variable.
>
> But I suppose the best solution would be not to use $php_errmsg, but to use mysql_error() -
> at least this function does not depend on configuration settings.

mysql_error is not set when mysql_connect fails, because there is no
actual mysql resource to get the error message from.

anyway i set track_errors=on (confirmed with phpinfo()) but i still get
the same message as above - no error is reported.

-jsd-



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 21.08.2003 10:41:03 von Antony Dovgal

On Wed, 20 Aug 2003 21:31:48 -0700
Jon Drukman wrote:

> mysql_error is not set when mysql_connect fails, because there is no
> actual mysql resource to get the error message from.
yes, there is no mysql resource at this moment.
just don't specify it and mysql_error() will tell something like "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)".

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 21.08.2003 11:37:05 von qwerty

--------------Boundary-00=_TPQYQL80000000000000
Content-Type: Multipart/Alternative;
boundary="------------Boundary-00=_TPQYLVC0000000000000"


--------------Boundary-00=_TPQYLVC0000000000000
Content-Type: Text/Plain;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable

If you reach to maximum mysql connection limit or link limit, mysql_conne=
ct
will fail.=0D
Check limits and current fullness.=0D
=0D
-------Original Message-------=0D
=0D
From: Jon Drukman=0D
Date: 21 A=F0ustos 2003 Per=FEembe 11:32:47=0D
To: mysql@lists.mysql.com=0D
Subject: Re: PHP mysql_connect randomly failing=0D
=0D
Antony Dovgal wrote:=0D
=0D
> On Tue, 19 Aug 2003 14:36:15 -0700=0D
> Jon Drukman wrote:=0D
=0D
>>Approximately 1% of the time it just fails, for no stated reason:=0D
>>=0D
>>Warning: mysql_connect() [http://www.php.net/function.mysql-connect]: =0D
>>in /var/httpd/htdocs/pi/pi.php on line 3=0D
>>mysql connect failed:=0D
>>=0D
>>Any ideas why this would be happening? PHP is version 4.3.1 (same =0D
>>results with the latest 4.3.3 release candidate), Mysql is 4.0.12=0D
> =0D
> You should turn =0D
> track_errors =3D On=0D
> in your php.ini (default value is Off), if you want to see last PHP err=
or
in $php_errmsg variable.=0D
> =0D
> But I suppose the best solution would be not to use $php_errmsg, but to
use mysql_error() - =0D
> at least this function does not depend on configuration settings.=0D
=0D
mysql_error is not set when mysql_connect fails, because there is no =0D
actual mysql resource to get the error message from.=0D
=0D
anyway i set track_errors=3Don (confirmed with phpinfo()) but i still get=
=0D
the same message as above - no error is reported.=0D
=0D
-jsd-=0D
=0D
=0D
=0D
-- =0D
MySQL General Mailing List=0D
For list archives: http://lists.mysql.com/mysql=0D
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dqwerty@sandwaves.org=
=0D
.
--------------Boundary-00=_TPQYLVC0000000000000
Content-Type: Text/HTML;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable


9">



10px 10px; FONT-FAMILY: Arial" bgColor=3D#ffffff background=3D"" scroll=3D=
yes ORGYPOS=3D"0" X-FVER=3D"3.0">

%" border=3D0>


TR>

AMILY: Arial" width=3D"100%">
If you reach to maximum mysql connection limit or link limit, mysql_=
connect will fail.

Check limits and current fullness.
 

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



Date: 21 A=F0ustos=
2003 Per=FEembe 11:32:47


Subject: Re: PHP m=
ysql_connect randomly failing

 
Antony Dovgal wrote:

> On Tue, 19 Aug 2003 14:=
36:15 -0700
> Jon Drukman <=
jsd@cluttered.com
> wrote:

>>Approximately 1% of the t=
ime it just fails, for no stated reason:
>>
>>Warning: =
mysql_connect() [ht=
tp://www.php.net/function.mysql-connect
]:
>>in /var/httpd/h=
tdocs/pi/pi.php on line 3
>>mysql connect failed:
>> >>>Any ideas why this would be happening? PHP is version 4.3.1 (sam=
e
>>results with the latest 4.3.3 release candidate), Mysql is =
4.0.12
>
> You should turn
> track_errors =3D On
&=
gt; in your php.ini (default value is Off), if you want to see last PHP e=
rror in $php_errmsg variable.
>
> But I suppose the best sol=
ution would be not to use $php_errmsg, but to use mysql_error() -
>=
; at least this function does not depend on configuration settings.
R>mysql_error is not set when mysql_connect fails, because there is no R>actual mysql resource to get the error message from.

anyway i se=
t track_errors=3Don (confirmed with phpinfo()) but i still get
the sa=
me message as above - no error is reported.

-jsd-



-=
-
MySQL General Mailing List
For list archives: lists.mysql.com/mysql">http://lists.mysql.com/mysql
To unsubscribe=
: h=
ttp://lists.mysql.com/mysql?unsub=3Dqwerty@sandwaves.org

.






ABLE>
ONT face=3D"Arial, Helvetica, sans-serif" size=3D2>______________________=
______________________________
<=
A href=3D"http://www.incredimail.com/redir.asp?ad_id=3D309& ;lang=3D9">=
3D"" align=3Dbaseline border=3D0>  IncrediMail - Email has=
finally evolved
-
asp?ad_id=3D309&lang=3D9">=
Click Here

--------------Boundary-00=_TPQYLVC0000000000000--

--------------Boundary-00=_TPQYQL80000000000000
Content-Type: unknown/unknown;
name="IMSTP.gif"
Content-Transfer-Encoding: base64
Content-ID: <62E9F75F-1A1D-4BF1-AB58-670D3C114EA1>

R0lGODlhFAAPALMIAP9gAM9gAM8vAM9gL/+QL5AvAGAvAP9gL////wAAAAAA AAAAAAAAAAAAAAAA
AAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJFAAIACwAAAAAFAAPAAAEVRDJ SaudJuudrxlEKI6B
URlCUYyjKpgYAKSgOBSCDEuGDKgrAtC3Q/R+hkPJEDgYCjpKr5A8WK9OaPFZ wHoPqm3366VKyeRt
E30tVVRscMHDqV/u+AgAIfkEBWQACAAsAAAAABQADwAABBIQyUmrvTjrzbv/ YCiOZGmeaAQAIfkE
CRQACAAsAgABABAADQAABEoQIUOrpXIOwrsPxiQUheeRAgUA49YNhbCqK1kS 9grQhXGAhsDBUJgZ
AL2Dcqkk7ogFpvRAokSn0p4PO6UIuUsQggSmFjKXdAgRAQAh+QQFCgAIACwA AAAAFAAPAAAEEhDJ
Sau9OOvNu/9gKI5kaZ5oBAAh+QQJFAAIACwCAAEAEAANAAAEShAhQ6ulcg7C uw/GJBSF55ECBQDj
1g2FsKorWRL2CtCFcYCGwMFQmBkAvYNyqSTuiAWm9ECiRKfSng87pQi5SxCC BKYWMpd0CBEBACH5
BAVkAAgALAAAAAAUAA8AAAQSEMlJq7046827/2AojmRpnmgEADs=

--------------Boundary-00=_TPQYQL80000000000000--

Re: PHP mysql_connect randomly failing

am 22.08.2003 03:18:37 von jsd

Antony Dovgal wrote:
>>mysql_error is not set when mysql_connect fails, because there is no
>>actual mysql resource to get the error message from.
>
> yes, there is no mysql resource at this moment.
> just don't specify it and mysql_error() will tell something like "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)".

that is true, but in this case, neither $php_errmsg nor mysql_error()
return anything. i print them both out when the connect fails and they
are both just blank.

-jsd-




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 22.08.2003 04:18:02 von daniel.rossi

funny i was just having the same problemo with mysql 3.22 on php3 the most =
painful system to debug i hate it to bits, anyway mysql_error doesnt get re=
turned on permission or database connection errors, i wonder if that is sou=
ghted out in mysql4 ?? maybe this is a php.net question

>>> Jon Drukman 08/22/03 11:18am >>>
Antony Dovgal wrote:
>>mysql_error is not set when mysql_connect fails, because there is no=20
>>actual mysql resource to get the error message from.
>=20
> yes, there is no mysql resource at this moment.
> just don't specify it and mysql_error() will tell something like "Can't c=
onnect to local MySQL server through socket '/tmp/mysql.sock' (111)".

that is true, but in this case, neither $php_errmsg nor mysql_error()=20
return anything. i print them both out when the connect fails and they=20
are both just blank.

-jsd-




--=20
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql=20
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Ddaniel.rossi@sbs.co=
m.au=20



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 22.08.2003 08:52:07 von Antony Dovgal

On Thu, 21 Aug 2003 18:18:37 -0700
Jon Drukman wrote:

> that is true, but in this case, neither $php_errmsg nor mysql_error()
> return anything. i print them both out when the connect fails and they
> are both just blank.

try to use error_reporting(E_ALL); and to see what happends.
maybe error logging will help you to solve your trouble.
I don't beleive in such bugs, it's a problem of your code imho.

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 22.08.2003 21:55:55 von rajesh kumar

Jon Drukman unknowingly asked us:
> Antony Dovgal wrote:
>
>> try to use error_reporting(E_ALL); and to see what happends.
>> maybe error logging will help you to solve your trouble.
>> I don't beleive in such bugs, it's a problem of your code imho.
>
>
> here's my code:
>
> mysql_connect() or die("mysql connect failed: $php_errmsg / " .
> mysql_error());
>
> that one line in a script all by itself will fail randomly with no error
> message. still think it's my problem?
>
> anyway i changed it to mysql_connect('localhost', 'username') and that
> seems to have straightened it out. i need to wait a few more days to
> see if it pops up again but over the last 24 hrs it has been ok.

I feel, that it does not always assume localhost. I assume that you're
using Apache.

There's no point $php_errmsg. I think you're being connected as
apache@localhost.

Try finding how you're connected using the MySql CURRENT_USER() function.

Also:


error_reporting (E_All ^ E_NOTICE);
$con = mysqk_connect ("localhost","uname","") or die(mysql_error());

?>

Try supplying all three arguments to mysl_connect().

--
[ Rajesh Kumar ]
__________________________________________
Meet the guy at http://www.meetRajesh.com/


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: PHP mysql_connect randomly failing

am 22.08.2003 22:33:13 von jsd

Antony Dovgal wrote:
> try to use error_reporting(E_ALL); and to see what happends.
> maybe error logging will help you to solve your trouble.
> I don't beleive in such bugs, it's a problem of your code imho.

here's my code:

mysql_connect() or die("mysql connect failed: $php_errmsg / " .
mysql_error());

that one line in a script all by itself will fail randomly with no error
message. still think it's my problem?

anyway i changed it to mysql_connect('localhost', 'username') and that
seems to have straightened it out. i need to wait a few more days to
see if it pops up again but over the last 24 hrs it has been ok.

-jsd-



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org