Solved

close all db connections "too many connections error"

Posted on 2009-05-06
7
1,248 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
Comment Utility
 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
Comment Utility
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
Comment Utility
please use  mysql_connect()
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:jblayney
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now