Fullposter
Mon 30 June 2008, 10:48 am GMT +0200
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
GiorgosK
Mon 30 June 2008, 01:07 pm GMT +0200
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 ?
Fullposter
Mon 30 June 2008, 03:42 pm GMT +0200
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
olaf
Mon 30 June 2008, 11:19 pm GMT +0200
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)
aaron_s
Tue 1 July 2008, 06:17 am GMT +0200
Sounds like you're using dream host ;) I have the issue with them with this. But its soooo cheap ;)
olaf
Tue 1 July 2008, 06:24 am GMT +0200
Dreamhost sucks, your website is down every day!!!
Fullposter
Tue 1 July 2008, 02:09 pm GMT +0200
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!
olaf
Tue 1 July 2008, 02:28 pm GMT +0200
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)
Fullposter
Tue 1 July 2008, 03:00 pm GMT +0200
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!
Fullposter
Tue 1 July 2008, 03:05 pm GMT +0200
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
Fullposter
Tue 1 July 2008, 03:20 pm GMT +0200
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!
olaf
Tue 1 July 2008, 03:22 pm GMT +0200
I don't know how it works on windows systems, you should host on a real (linux) server
Fullposter
Tue 1 July 2008, 03:35 pm GMT +0200
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)
olaf
Tue 1 July 2008, 04:52 pm GMT +0200
the problem is that maybe your whole application need to get updated after the move to another plattform
Nikolas
Tue 1 July 2008, 07:14 pm GMT +0200
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.
GiorgosK
Tue 1 July 2008, 09:10 pm GMT +0200
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
olaf
Tue 1 July 2008, 09:43 pm GMT +0200
on a linux host it's possible to creaste a my.cnf file for each user ;)
Nikolas
Wed 2 July 2008, 11:01 am GMT +0200
on a linux host it's possible to creaste a my.cnf file for each user ;)
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.