Skip to main content
Known Participant
September 6, 2010
Answered

too many connections

  • September 6, 2010
  • 1 reply
  • 751 views

hi,

i created a dynamic site with dreamweaver however i only ahve about 10 users logged in at any one time however they are getting the too many connections error in connection file thrown up.

i checked with the host who said it has a max of 25 connections and this is more than enough.

i read a bit on the net and say that you can just remove the pconnect that the connection file has.

why does dreamweaver create the connection file like this and what are the advantages/disadvantages of having the pconnect removed?

i have currently this line in my connection file:

$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);

do i just change it to this:

$conn = mysql_connect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);

?

many thanks

This topic has been closed for replies.
Correct answer

Short answer is "Yes">

mysql_pconnect() leaves the connection open for future use from the same user. This is more efficient in some cases. In other cases, obviously not so. It would seem that Adobe made an assumption.

From W3 Schools: "The connection will not be closed when the execution of the script ends       (mysql_close() will not close connection opened by mysql_pconnect()). It       will stay open for future use."

Barry

1 reply

Correct answer
September 6, 2010

Short answer is "Yes">

mysql_pconnect() leaves the connection open for future use from the same user. This is more efficient in some cases. In other cases, obviously not so. It would seem that Adobe made an assumption.

From W3 Schools: "The connection will not be closed when the execution of the script ends       (mysql_close() will not close connection opened by mysql_pconnect()). It       will stay open for future use."

Barry

deansy55Author
Known Participant
September 7, 2010

thanks barry,

so does dreamweaver create the pconnect by default?

i am guessing that is what was throwing the error "too many connections" should this resolve this now by changing?

also one last thing if you dont mind.

where should i add mysql_close() ? should this be in my user_logout.php page?

many thanks again for your help.

September 7, 2010

I checked some code that I have and I would have to say that it appears that DW is using pconnect by default.

Resources are freed when the the script ends with a non-persistent connection, so you technically don't need the close().

Barry.