Forum Moderators: open

Message Too Old, No Replies

having problem with mysql connection

giving warning as unable to connect to mysql in localhost(10048)

         

rajeshp

4:57 am on Mar 7, 2009 (gmt 0)

10+ Year Member



Hi all,
i am running one javascript from a php file.In Javascript i am connecting to server through xmlhttprequest object for every one second.With that I am getting error like

Warning:mysql_error(),can't connect to mysql in localhost(10048).

i searched for this in google.But i did not find required one.
After some times it solved and working fine,after some time the same issue occurs.

Could any one help me to resolve this...
any reply may helpful to me..

Thanks in advance.

rocknbil

3:08 pm on Mar 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard rajeshp,

i am connecting to server through xmlhttprequest object for every one second.

By this do you mean you are making a mysql query every second?

Are you able to make a single connection without error?

Are you closing each connection after the process is finished?

It could be exceeding maximum open connections, or a problem with the mysql server, or some other user is using up resources. I have seen the 10048%2

bleak26

7:22 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



i maybe wrong but try mysql_pconnect(). some people dont like it, but it only uses one connection and re uses it (afaik). if you are using a shared mysql server there may not be enough connections availible becuase other peoples poor code is not closing the connection or your hosting is over burdoned . if you have full access to mysql you can view the connection pool and judge this for you self.

also on a side note i get more mysql has gone away errors when i am acidentally using the full server address rather than the localhost.

either way as rocknbil said check you are closing your connections.

rajeshp

5:39 am on Mar 9, 2009 (gmt 0)

10+ Year Member



Thanks rocknbil and bleak26 for your replies.Now I will try the suggestion which is given by you,i.e,closing the connection after the all operations with database.I will inform you if still have problems or doubts..

Thanks once again for your reply

rajeshp

6:20 am on Mar 9, 2009 (gmt 0)

10+ Year Member



Hi rocknbil, i tried your suggestions,i.e closing the connections with mysql after each conection.But still having the same problems.

Actually,i need that connecting to mysql for every second in a page more than once.

Here i am writing the problem clearly...

I want to a countdown timer for my auction web site to bid on product.So for every product i need a countdown timer.So,to get values from mysql for every second for every product is making that issue.

For this actually i am doing this..

Initially i have written one javascript function for one product to change the time and product price for every second.If it is working fine for one product,then i call the same function for all products.Actually this is happen at a time for all products.

For that i followed the above procedure.First tell me am i going in a right way ?if not please help me to solve the issue.And give me the suggestion to proceed.

Thanks for your reply