/    Sign up×
Community /Pin to ProfileBookmark

Too Many Connections

I tried going to one of my websites this morning, and had this error message…

Warning: mysql_connect(): Too many connections in /home/myspace/domains/mydomain.com/public_html/index.php on line 25
Couldn’t Connect To SQL

The first lines of index.php are as follows…

15// get the connection variables
16 include(‘wroof/admin/connect.inc.php’);
17 $user = $connect[0];
18 $pass = $connect[1];
19 $db = $connect[2];
20 $path = $connect[3];
21
22 $csspath = $path.”wroof/css/wroof.css”;
23
24//create the connection
25 $link = mysql_connect(“localhost”,$user, $pass);
26 if(! $link) die(“Couldn’t Connect To SQL”);
27 mysql_select_db($db, $link) or die(“Couldn’t open $db: “.mysql_error());

Connect.inc.php just has the connect variables in text format.

The site, [url]www.wroof.com,[/url] has been up and running for months without a problem.

Is this likely to be a php script problem (my problem), or a server problem (my host provider’s problem)?

Thanks
CTB

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 27.2004 — if you can use mysql_pconnect(), use it instead of mysql_connect()
Copy linkTweet thisAlerts:
@sydelctDec 27.2004 — Curious, what really are the advantages of mysql_pconnect over mysql_connect?
Copy linkTweet thisAlerts:
@ShrineDesignsDec 27.2004 — it tries to re-use any previous connection to the server
Copy linkTweet thisAlerts:
@AdamGundryDec 27.2004 — ...but also doesn't close the link when PHP exits, so it can be reused. This is mainly for situations where establishing a connection takes a long time, and will probably be less useful in your case, since it may cause even more connections to be hanging around.

The [url=http://dev.mysql.com/doc/mysql/en/Too_many_connections.html]MySQL manual[/url] has some useful information on this error.

Adam
Copy linkTweet thisAlerts:
@chestertbauthorDec 28.2004 — Thanks guys.

I'll get the server provider to increase his maximum available connections as per the MySQL manual.

Cheers

CTB
Copy linkTweet thisAlerts:
@sydelctDec 28.2004 — in the long run, mysql_pconnect is more troublesome "IF" there are many users who make a mysql_pconnect at the same time because there will be no more "unused" connections to reuse and thus mysql opens a new connection. am i right?

thanks for the info, at least now i know how to weigh mysql_connect versus mysql_pconnect
×

Success!

Help @chestertb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...