Solved

close all db connections "too many connections error"

Posted on 2009-05-06
7
1,255 Views
Last Modified: 2013-12-13
Hello,

a shared web server i use recently got an error "Too many connections" all my php code closes the recordset connection at the bottom of page so i thought it may be a database connection. We ended up increasing the connection limit to 500.

i added this to one test site where i know only 1 or 2 users is on the site
 mysql_close($mine);

but we still have 13 connections , but all with Kill runs on them (whatever that means)

is their anything I can add to my website footers to make sure all the recordset and db connections close after page loads?

could it be another problem i dont see?

is their an another server based solution? (windows server)
<?php mysql_close($mine); ?>

Open in new window

0
Comment
Question by:jblayney
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:ali_kayahan
ID: 24319474
 Hi jblayney ,
      It seems something related with your host firm.Even if you have 13 active connections it shouldnt create any issues as you mentioned above.Also using mysql_close() is not necessary if you are not using persistent connections as far as all connections will be closed at the end of script execution.
     To minimize the DB connections you should use singleton pattern , during your database connections, but this is not the exact solution you need.
     If i am not wrong you get the error not because of active connections made from an mysql account,  generally multiple connections from different mysql accounts cause this kind of issues.
    Do you get the error when you run phpmyadmin or some kind of other database management tools ?

0
 
LVL 1

Author Comment

by:jblayney
ID: 24320672
hello,

yes, i fist noticed it using phpmyadmin

i also use dreamweaver to do my connections and basic coding. it closes all recordsets. eg.. it looks like is makes persistant conenctions.. (pconect)

$mine = mysql_pconnect($hostname_mine, $username_mine, $password_mine) or trigger_error(mysql_error(),E_USER_ERROR);
0
 
LVL 7

Accepted Solution

by:
ycTIN earned 125 total points
ID: 24321548
please use  mysql_connect()
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:jblayney
ID: 24321880
ill try, but this is  built in dreamweaver function, how could they make such a mistake, any thoughts?
0
 
LVL 7

Expert Comment

by:ycTIN
ID: 24321972
FYI
http://www.eukhost.com/forums/f18/going-_pconnect-_connect-modifying-dreamweaver-5325/

dreamweaver is not professional php ide, just strong in layout design
0
 
LVL 1

Author Comment

by:jblayney
ID: 24325475
Hello,

i actually found that thread before i posted here. it is easy to change to connect, you do that simply in your connection file.

i just guess im looking for  the bigger explanation. I have used dreamweaver for many years and many versions. they get many things correct and it seems silly that they would overlook something like this.


i am going to change all the sites i built on that server to mysql_connect and see what happens
0
 
LVL 1

Author Closing Comment

by:jblayney
ID: 31578704
yes, dreamweaver does it wrong, i changed all the sites to mysql_connect() and the issue is gone, i was able even able to go into my dreamweaver configuration and change the default and submitted it as an issue to adobe, my steps to modify dreamweaver is on my blog here
http://darkstar-media.blogspot.com/2009/05/mysqlpconnect-and-dreamweaver.html
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP AJAX JSON 2 61
Really simple no curl. Send a post 3 times 4 25
PHP curl issue VERBOSE output 18 44
Eloquent ORM manual paginator defaults to simple 2 24
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question