determine if db is open [SOVED]
Posted: Thu Jun 01, 2006 6:38 am
how to determine if db is open after connection
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
bdlang wrote:What's the context, i.e. is this from within PHP? What DBMS?
By rule, the connection will be closed once the script stops execution, (as long as it's not a persistent connection) so there is really no reason to close the connection anyway. If you have multiple database connections per script, which isn't very likely, then you might have reason to close each when you're done with it to save system resources. BTW, the function you're looking for is aptly named mysql_close().ddragas wrote:
db=mysql
and it is within PHP
script is:
connect to db and select table
execute some query
if connection to database is open then close it
Hmm. I must say that's the oddest bit of advice on a PHP forum I've ever come across.Weirdan wrote:if you want a man to be dead, you just shoot him in the head. What's the point of checking if he was alive prior to shooting?
if you want to close db connection, just do it
Code: Select all
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if ($conn)
{
// Yeah, I am connected
}
// later on, toward the end of the script
// If we are still connected, disconnect
if ($conn)
{
mysql_close();
}
?>if the intent was to kill - then yes. But if you just want to be sure the one is dead...bdlang wrote:if in fact the actual motive to shoot was to kill.