#native_company# #native_desc#
#native_cta#

class for database connection and database selection

By Rameshwor Maharjan
on June 18, 2006

Version: 1.0

Type: Full Script

Category: Databases

License: GNU General Public License

Description: uses of constructor in class for database connection and selection

<?
class db 
{
 var $link;

  function db($host,$dbUser,$dbPass,$dbName)              //constructor 
  {
   	 $this->link=mysql_connect($host,$dbUser,$dbPass);                //return link identifier if success,or false on failure 
	if($this->link==false)
	{
	  echo("Database connection failed");       
	}
	else
	{
	  if(mysql_select_db($dbName,$this->link)==false)          //return true on sucess,or false on failure
	  {
	    echo("Database not found");
	  }
	}
  }
}

 $obj=new db("localhost","root","","databasename");
?>