Monday 15 February 2010

php - Close mysqli database connections after AJAX calls -



php - Close mysqli database connections after AJAX calls -

i'm handling ajax calls in ajax.php establishes database connection using mysqli_connect() function , closing connection right using mysqli_close() function before echo , exit.

still seems connections remain open, cause after amount of ajax calls i'm getting 'to many connections' error.

so i'm wondering, best way create sure db connections closed after each call? there way check how many connections open troubleshoot problem?

ajax.php:

$con = mysqli_connect("localhost","my_user","my_password","my_db"); // ....some php code... echo 'result'; mysqli_close($con); exit();

this might help you:

$connection = new mysqli(.....) // stuff $thread = $connection->thread_id; $connection->kill($thread);

from php.net:

this function used inquire server kill mysql thread specified processid parameter. value must retrieved calling mysqli_thread_id() function.

php ajax database mysqli connection

No comments:

Post a Comment