too many connections error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
wayne1234
Forum Newbie
Posts: 2
Joined: Thu Feb 17, 2005 10:10 am

too many connections error

Post by wayne1234 »

use a webhosting company with php4 and mysql

I use dreamweaver MX

90% of the time all is ok but sometimes customers get a message :too many connections"

Is there something fundamentally wrong with my code?
The syntax is fine as this works, just wondered if the errors due to poorly written code by dreamweaver?

It is as follows
dreamweaver creates a connection file that is called from the page and it uses the mysql_pconnect funtion

on my page I have

Code: Select all

mysql_select_db($database_inventory, $inventory); 
$query_Recordset1 = "SELECT * FROM entries"; 
$Recordset1 = mysql_query($query_Recordset1, $inventory) or die(mysql_error()); 
$row_Recordset1 = mysql_fetch_assoc($Recordset1); 
$totalRows_Recordset1 = mysql_num_rows($Recordset1); 

mysql_select_db($database_inventory, $inventory); 
$query_Recordset2 = "SELECT * FROM store"; 
$Recordset2 = mysql_query($query_Recordset2, $leamingtontri) or die(mysql_error()); 
$row_Recordset2 = mysql_fetch_assoc($Recordset2); 
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

BUNCH OF HTML
THEN to write to the database

Code: Select all

mysql_select_db($database_inventory, $inventory); 
$query = "INSERT INTO customer VALUES ('', '$date', '$rvarevent','$rvarfname', '$rvarlname', '$rvarmember','$rvaremail', '($rvarareacode)-$rvarphone', '$rvarstreet','$rvarcity', '$rvarprov','$rvartransactionfee', '$rvarsubtotal','$charge_total','$response_order_i
d','$cust_id')"; 
$result=mysql_query($query) ; 

mysql_select_db($database_inventory, $inventory); 
$query = "INSERT INTO stock VALUES ('', '$date', '$item','$name, '$id)"; 
$result=mysql_query($query) ;

then a bunch of html and at the bottom I have

Code: Select all

mysql_free_result($Recordset1); 
mysql_free_result($Recordset2);

feyd | please post using the formatting tags, such as

Code: Select all

[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your host may limit the number of active persistant connections. Connections may be used by connecting too often (i.e. more than once per page request)

you may want to look into how many connections of each type (persistant and non) you can have open inside your host's documentation.
wayne1234
Forum Newbie
Posts: 2
Joined: Thu Feb 17, 2005 10:10 am

persistent connection

Post by wayne1234 »

I do not quite fully understand the advantage of using a persistent connection. I use this because this is what dreamweaver creates.

Would I be better to use mysql_connect?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that depends on your host's choices in allowing so many connections. Persistant connections will typically speed up a page, but only marginally.
Post Reply