Am I creating too man MySQL connections?

Title should be "Am I creating too manY MySQL connections?
All my mySQL table query classes extend my root class which establishes a connection. Should I be establishing a singleton class, a “require_once” or am I ok?
Here is my root class

Abstract Class scheduler_root_module_db {
  Protected $dbcnx;
  Protected $pServer = // <omitted for this sitepoint thread>
  Protected $pUsername // <omitted>
  Protected $pPassword = // <omitted>
  Protected $pDataBaseName = //<omitted>
  
  Public Function __Construct() {
 // Purpose:	Prepare the database for i/o
 // Requires:	active server and database
 // Returns:	Database object
 // On Error:	ends session
 
   // connect to the server
	$this->dbcnx = @mysql_connect($this->pServer, $this->pUsername, $this->pPassword);
	if (!$this->dbcnx){
		exit('<p>Unable to connect to the database server.</p>');
	} // end if
   
  // select the database
	if (!mysql_select_db($this->pDataBaseName)) {
		exit(mysql_error($this->dbcnx)); 
	} // end if
  } // end Function __Construct

Thanks,
grNadpa

(irrelevant note: Ultimately I plan to Throw an error rather than simply exit ).

You only need to connect to the database once per script (unless you need to have a connection to another database at the same time) so multiple connections will simply use up more resources.

Thanks to tangoforce who wrote:

You only need to connect to the database once per script

If I understand “script” in the context of inheritance; I believe you are telling me that I am, indeed, creating too many connections if I instantiate more than one child of this [scheduler_root_module_db] class between echo statements.

Yes?

Script being the file requested by the browser which then uses your child class.

You only need to connect to your database once not multiple times so yes, you are connecting too many times.

Your connection(s) remains open until you manually close it or the script execution finishes so once you have one open connection you can use it for many queries.

Be aware that when calling mysql_connect multiple times with the same parameters you always get the same connection back. So you really aren’t hurting anything (or using extra resources) by doing what you are doing.