473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DB- Too many connections - Should I be closing after each call?

Hi There,
Been working in a PHP / MySQL project I took over code development for.
Today when testing new changes suddenly started getting "Failed to
connect to the database" errors.

When logged into phpmyadmin it said:

Error
MySQL said:

Too many connections
Now does this mean that becuase the website I'm working on uses shared
webhosting, that there could be other people viewing websites on the
same server and it has just got too busy?

Or could matters be made worse by the fact that I notice in the code I
took over the original coder never seemed to expicitly close a
connection to the DB.

For example, he would have a funtion in a header file that would open /
connect to DB run an SQL query and then exit. Never an explicit close.
Is this very bad? He was a compotent programmer so I assumed that the
connectoions must close themselves, but now with this error I thought I
better check.

Kind regards

Jul 23 '05 #1
1 2178
Gr*************@lycos.co.uk wrote:
MySQL said:
Too many connections
See this page for description of that error:
http://dev.mysql.com/doc/mysql/en/to...nnections.html
Be sure to read the users' comments, there are some tips about this
error for PHP programmers.
Now does this mean that becuase the website I'm working on uses shared
webhosting, that there could be other people viewing websites on the
same server and it has just got too busy?
That'd be my first guess. The default maximum number of connections on
a new MySQL installation is 100. This is determined by a startup option
for mysqld, and the system administrator is the one who can alter this
value. See the above web page I referenced.

You should talk to your hosting service about raising the maximum number
of connections on their MySQL server, if it is set too low.
For example, he would have a funtion in a header file that would open /
connect to DB run an SQL query and then exit. Never an explicit close.
Is this very bad?


http://us4.php.net/manual/en/function.mysql-close.php

"Using mysql_close() isn't usually necessary, as non-persistent open
links are automatically closed at the end of the script's execution."

So it depends on whether the connections are opened as regular
connections or persistent connections. In the case of PHP, it's the
difference between using mysql_connect() or mysql_pconnect().
See users' comments on
http://dev.mysql.com/doc/mysql/en/to...nnections.html for more
info related to getting this error in PHP scripts.

Regards,
Bill K.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eben Goodman | last post by:
I have been getting the following error consistently every few days: Warning: Too many connections in /path/to/connection.php I altered the max_connections in my.cnf to allow for 300...
3
by: john bailo | last post by:
SqlConnection.Open, from a web application, threw: /Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled...
1
by: hananiel | last post by:
Hello: We have a a two tier application connecting to sql server through remoting. The business objects are single call objects. We are opening and closing connections using ADO.NET command...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
37
by: Joshua Ruppert | last post by:
When I'm using FastCGI do I need to code differently than I do when using regular CGI? Because the PHP.exe processes don't go away do global variables stick around from page request to page...
2
by: osmarjunior | last post by:
Hi, I'm using ODBC to connect to the dbms (Postgresql v8.1, in Windows server). After a few program open/close I get the message "Sorry, too many clients already". I believe my database class...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
6
by: Steve Ricketts | last post by:
I have a webservice written in VB.net that opens a connection to SQL Server 2000 with a connection string. The connection remains open for the life of the web service so the ADODB.connection is...
4
by: kessa | last post by:
Hi Guys, I've recently had a problem with my site displaying a "system resources exceeded" error message ... and whilst searching this site for a solution (which I think I've now found) I came...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.