Solved

close all db connections "too many connections error"

Posted on 2009-05-06
7
1,261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
$_SERVER Variable question 31 56
Inserting results of While loop to sql server 5 38
PHP mail() function not working... 8 36
Add Logo to Bookmark and Tab Headings in Browser 3 33
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 dynamically set the form action using jQuery.

730 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