tags:

views:

35

answers:

3

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

+1  A: 

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

Aaron Harun
+3  A: 
is_resource($con)

gives false if the connection is closed.

Artefacto
A: 

You can test the connection by doing a simple mysql_ping, which will re-open the connection if it's closed.

amphetamachine