mysql - How to close database connection in php while database file is included? -
i have page pae1.php has code like
include_once('db.php');
in db.php connection established
$con= mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("dbname") or die(mysql_error());
i run query on page1.php as
$delete_s1ql="delete tbl_info id='$id' "; $res_del=mysql_query($delete_s1ql) or die(mysql_error());
now want close database connection on page1.php.
how can this?
change db.php (to make sure selected database bound resource):
$con= mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("dbname", $con) or die(mysql_error());
in page1.php add end (use global resource-variable close correct connection):
mysql_close($con);
ps: take @ pdo better way connect , talk database.
Comments
Post a Comment