0

i want to close an opened connection using mysql_close() but when i go at my server and check the amoutn od opened connections in my server the connections are increased! for example i have 100 opened connections in my mysql data base

and i have a page with this code:

<?php include "configa/configuration.php";
$con = mysql_connect($sql['host'],$sql['user'],$sql['password']);
if ($con) echo "connected<br>";
mysql_close($con);  
if (!$con) echo "disconnected";
?> 

every time i refresh page a new connection is initialized and only connectid shows up in page. what could possibly be wrong

in this way with 1000 page refresh my sql server gets disconnected

  • 1
    [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](http://j.mp/XqV7Lp). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. – Kermit Jan 25 '13 at 22:32

2 Answers2

0

Connection.close() actually doesn't remove the connection from connection pool. try using Connection.Dispose() to release the connection completely. But you can't open that dispose connection again so take care before closing it.

More about close: Close Or you can set the connection pooling to false.

Arpit
  • 12,767
  • 3
  • 27
  • 40
0

The "Connections" value from the SHOW STATUS is essentially a counter of the number of connections that have been made to the MySQL server since it was started; it's not the number of currently open connections.

To show the current connections (those that are still open), use

SHOW PROCESSLIST
spencer7593
  • 106,611
  • 15
  • 112
  • 140