|
Posted by Phil Steer on 02/07/07 10:25
I have just had a mySQL database added to my hosting account (NetNation) and
am experimenting with building an HTML page from the database using PHP.
However, although my test works (the page displays as expected), when I
request the test page multiple times I get the error:
Warning: mysql_connect(): User 'username' has exceeded the 'max_connections'
resource (current value: 10)
It then takes hours for the connections to timeout.
As far as I can see there is nothing wrong with my PHP code, which uses
mysql_close to explicitly close the connection opened with mysql_connect:
<?php
$db = mysql_connect( "hostname", "username", "password" ) ;
mysql_select_db( "database", $db ) ;
$sql = "SELECT * FROM articles" ;
$res = mysql_query( $sql, $db ) ;
echo "<html>" ;
echo echoHead( mysql_result( $res, 0, "title" )) ;
echo "<body>" ;
echoBorderTop() ;
showImage( mysql_result( $res, 0, "text" ), mysql_result( $res, 0,
"image" )) ;
echoBorderBottom() ;
echo "</body>" ;
echo "</html>" ;
mysql_close( $db ) ;
return ;
?>
(echoHead, echoBorderTop, showImage, and echoBorderBottom are simply
functions that I have written to help build the page - they make no calls to
database functions themselves)
Any suggestions as to the cause of the exceeded connections problem would be
much appreciated. Many thanks.
Navigation:
[Reply to this message]
|