Db connectivity is handled by an include.
I want to run this command: mysql_close($con);
Only if we currently have a connection. Something like isset()?
Thanks Hamad
is_resource($con)
gives false if the connection is closed.
&& get_resource_type($con) === 'mysql link' to make sure is a mysql link resource.You can use mysql_ping($con);
Depending on your PHP version, the older ones would reopen the connection if it was closed automatically. It shouldn't do that in PHP5
Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: mysqli_ping()You can test the connection by doing a simple mysql_ping, which will re-open the connection if it's closed.