Develop PHP Website for Learning Web Design Free Online
  Home   |   Forums   |   DevCMS
  Join   |   Log In
 
   

MySQLi Tutorials - Learn MySQLi

Tutor at Develop PHP
Closing a MySQLi Connection
By: Adam      Created: Jul 15, 2009      Views: 1949 Tweet This Page  Post page to Facebook  Post page to Facebook

When a PHP script completes execution, any open mysqli_connect() instances will be closed automatically to help beginners free up resources in case they happen to forget to close a connection. If we want to make sure that all resources are freed up after we query the database, we use the mysqli_close() function. This will assure that the connection is closed at the exact line in the script where you write it in.

Here is an example of using mysqli_close() to close a mysql connection that we have open:
Learn HTML
<?php 
// Include the connection script to connect to the database in any script
require_once "connect_to_mysql.php"

// Now you can use the variable $myConnection from our include script
// Execute all queries needed then close your connection

// Run the close connection function
mysqli_close($myConnection);

// If you attempt a query here in your script it will fail
?>




                                   Creating Tables Through Script


Comment on Closing a MySQLi Connection




Search Tags:
Closing   ·  a   ·  MySQLi   ·  Connection   ·  
 
 
Arbitrary Links and Archives
Home
Active Forums
Members
SIte News
Link To Us
Gear
2009 Forum Archive
Programming Courses
Learn HTML
Learn CSS
Learn PHP
Learn MySQL
Learn Javascript
Learn jQuery
Learn ActionScript 3.0
Learn Java
Learn XML
DevelopPHP Requires Flash Player
Get Adobe Flash player
___________________________________________

Terms of Use  •  Privacy  •  Admin Notes

©2010 developphp.com   |   Powered By FlashBuildingHolder