Solved

close all db connections "too many connections error"

Posted on 2009-05-06
7
1,257 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

829 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