Connect to mySQL db ONLY if not already connected
Posted on 2007-11-28
I want to connect to a mySQL database but ONLY if I am not already connected to a database.
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
mysql_select_db("$DBName") or die("Doh!");
So if my script is called as an include from a script that has already established a connection with the DB then it should not connect again.