MySQL Forums
Forum List  »  Newbie

How do I release connection?
Posted by: Steve George
Date: February 02, 2005 02:56PM

Hi everyone,

There is probably a simple answer to this, but I'm very new to MySQL and can't figure it out.

I am developing a site which has a login screen to access a members area. I downloaded a set of code snippets which connect to the database, verify the user and redirect them to the respective page if the details are correct.

The snippets are in three parts;

"Connection script" (db.php)

<?
$dbhost = '******.com';
$dbusername = '******_db';
$dbpasswd = '****';
$database_name = '*****_db';

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>

"Validation Script"

Long and complicated, but it works OK :)

"Logout Script"

<?
session_start();
if(!isset($_REQUEST['logmeout'])){
echo "<center>Are you sure you want to logout?</center><br />";
echo "<center><a href=logout.php?logmeout>Yes</a> | <a href=javascript:history.back()>No</a>";
} else {
session_destroy();
if(!session_is_registered('FirstName')){

include 'loginagain.php';
}
}
?>

Everthing appears to work OK, but I have just recently got the error:

"Warning: mysql_pconnect(): Too many connections in /home/www/awdd.org.uk/db.php on line 12. Couldn't connect to server."

when I try to connect. I'm guessing this is because the logout script is ending the users session, but not releasing the connection. As I say, the site is being developed and connections from my IP are the only ones registered in the logs.

I would be very grateful if someone could enlighten me as to the best way of adapting the scripts I already have, or where I might find more useful ones, that do release the connection when the user logs out.

Thanks in advance for any advice. :D

-- If at first you don't succeed...Ask someone who knows!! --

Options: ReplyQuote


Subject
Written By
Posted
How do I release connection?
February 02, 2005 02:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.