5, December 2008

Occasional Failures In Php Connect Or Select mySQL DB - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Occasional Failures In Php Connect Or Select mySQL DB
« previous next »
Pages: [1] Print

Author Topic: Occasional Failures In Php Connect Or Select mySQL DB  (Read 609 times)
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« on: Jun 30, 2008, 11:48:27 AM »

I have a funny problem with Php, and I was wondering if someone either met it already or has some ideas about a solution.

All works smooth, but occasionally although FTP and mySQLAdministrator still work fine and the site is accessible, Php apparently fails to connect to the DB.

It may happen a few times a day, normally lasts about one or two minutes, then it can connect again. It truly seems something in the Php/DB interface. Either it cannot connect to it, or it cannot select the right db.

The code snippet that seems affected is this:

   $sqlConnect=@mysql_connect($host, $user, $pass);
   $isConnected=($sqlConnect)?@mysql_select_db($db):0;
      if(!$isConnected){//error message ensues

That snippet works as I said - it just stubborny and occasionally fails and throws the error.
Any idea? Something gross that has escaped my attention?

Thanks in advance

« Last Edit: Jun 30, 2008, 11:53:55 AM by Fullposter »
What's HTML?
****
Gender: Male
Posts: 408
2466 credits
Members referred : 2



« Reply #1 on: Jun 30, 2008, 02:07:58 PM »

Not a MySQL expert
but it seems that if it "occasionally" don't work
it might be a problem in your database server  !!!
not responding, overloading ?
Have you tried your code on your local machine ?


Last blog : Popular SEO Techniques
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #2 on: Jun 30, 2008, 04:42:27 PM »

Yes as a matter of fact on localhost this issue never occurs.
Of course I have contacted several times the server administrator but he says his logs report nothing. The database seems ok for also when I get that php error, I can still smoothly query the server db via mysql administrator.

So, if no one has other ideas, has someone any clue about what exactly could be wrong on the server? If so, I could give some good hint to the administrator.

For some funny reason it affects only my site, for the server hosts other sites also apparently (i don't know all the details unfortunately and you know how difficult it can be to talk with a server admin)

thank you
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Jul 01, 2008, 12:19:59 AM »

sounds to me that the server doesn't accpet no more connections (hosting companies will say always that everything is right)
try debug the whole stuf (send an email to yourself if an mysql connection error happens)


Last blog : Just a better Internet portal provided by Google
Community Supporter ?
Hunky Junky Monky Man!
**
Gender: Male
Posts: 68
436 credits
Members referred : 0


Schwa?


« Reply #4 on: Jul 01, 2008, 07:17:02 AM »

Sounds like you're using dream host Wink  I have the issue with them with this.  But its soooo cheap Wink
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Jul 01, 2008, 07:24:39 AM »

Dreamhost sucks, your website is down every day!!!


Last blog : Just a better Internet portal provided by Google
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #6 on: Jul 01, 2008, 03:09:45 PM »

OK I have an option maybe: any idea what strings in php.ini or mysql inis may affect these behaviours and what their better values could be? There is plenty of stuff there and maybe a tailored reply would help me at least to look to the right needle in the haystack :-)
maybe i can persuade my server admin to check them

thank you a lot!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Jul 01, 2008, 03:28:41 PM »

OK I have an option maybe: any idea what strings in php.ini or mysql inis may affect these behaviours and what their better values could be? There is plenty of stuff there and maybe a tailored reply would help me at least to look to the right needle in the haystack :-)
maybe i can persuade my server admin to check them

thank you a lot!

sounds like a mysql setting (max. connections (my.cnf)


Last blog : Just a better Internet portal provided by Google
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #8 on: Jul 01, 2008, 04:00:23 PM »

I found a my.ini file nbut no cnf. Is the my.ini the file one can edit to affect mysql behaviours? It is... empty!
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #9 on: Jul 01, 2008, 04:05:40 PM »

by the way, since it is empty or, better, that my.ini includes only two lines of text, any good tutorial about how to configure it with more option, of course if you advise for it?

I am doing my 'homework' on google but as you an imagine i am overwhelmed with data that doesn't meet my need so maybe some of you know already where i can find directions (or just give them here) about a few good edits to that file uh?
thank you
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #10 on: Jul 01, 2008, 04:20:21 PM »

ok what if I add these:

max_allowed_packet = 16M
wait_timeout = 7200
key_buffer = 384M
max_connections = 500

Of course suggestions are appreciated
The only problem I need to prepend in square brackets some sort of command, apparently [mysqld]
but the server is a windows server and i don't know if [mysqld] is correct or it should be something like, say [WinMysqld] and if it's case sensitive or what.
Damn computers!
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Jul 01, 2008, 04:22:50 PM »

I don't know how it works on windows systems, you should host on a real (linux) server
« Last Edit: Jul 01, 2008, 04:24:22 PM by Olaf »


Last blog : Just a better Internet portal provided by Google
I love Pokemon
*
Posts: 13
86 credits
Members referred : 0


« Reply #12 on: Jul 01, 2008, 04:35:09 PM »

I don't know how it works on windows systems, you should host on a real (linux) server
for now i am stuck there, well yes we are planning to move elswehere, in the meanwhile a windows solution too would be useful (well not only for me after all the htread is public lol)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #13 on: Jul 01, 2008, 05:52:08 PM »

the problem is that maybe your whole application need to get updated after the move to another plattform


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #14 on: Jul 01, 2008, 08:14:20 PM »

This settings should be different in each server. I mean it depends on your server's hardware, the other services that you are using, the traffic, the type of the queries you run, etc.

Anyway as my.cnf is supposed to give directives for the whole server, I don't think that your hosting company will give you the ability to change them.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
What's HTML?
****
Gender: Male
Posts: 408
2466 credits
Members referred : 2



« Reply #15 on: Jul 01, 2008, 10:10:07 PM »

This settings should be different in each server. I mean it depends on your server's hardware, the other services that you are using, the traffic, the type of the queries you run, etc.

Anyway as my.cnf is supposed to give directives for the whole server, I don't think that your hosting company will give you the ability to change them.

If they give you such ability probably its somewhere in their Help Files and tutorials or knowledgebase of how to do things (tweak things) in your account


Last blog : Popular SEO Techniques
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6487
39754 credits
Members referred : 374


It's time to use PHP5!


« Reply #16 on: Jul 01, 2008, 10:43:32 PM »

on a linux host it's possible to creaste a my.cnf file for each user Wink


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #17 on: Jul 02, 2008, 12:01:43 PM »

on a linux host it's possible to creaste a my.cnf file for each user Wink

Are you sure? If that is true, then the host needs one mysql server per user as it is a server that uses those directives.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7811
Tags : php.mysql database connect db select Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Occasional Failures In Php Connect Or Select mySQL DB
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 05, 2008, 04:29:20 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 38.000
Total Topics: 7.685
Total Members: 4.470
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: srinivasarao

34 Guests, 3 Users online :

9 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.