MySQL PHP Class Object

Creating a new object with which you can perform MySQL queries is easy. To do this use the function explained below.

mysqlClass function

This function is the constructor function. This function is used to instantiate a new MySQL class object and make a connection to the selected database.

function mysqlClass($h,$u,$p,$d) {
	if($this->c = @mysql_connect($h,$u,$p)) {
		return $this->selectdb($d);
	}
	$this->errors();
	return false;
}

Parameters

  • MySQL Host (required) - This will most likely be set to "localhost" but could be an I.P. address.
  • MySQL Username (required) - This is the username you intend to connect to your database with.
  • MySQL Password (required) - This is the password you intend to connect to your database with.
  • MySQL Database (required) - This is the database you intend to connect to.

Return Value

Returns TRUE upon successful connection and FALSE on failure.

Examples

This function is called when you create the MySQL class object like so:

$connection = new mysqlClass($mysql_address,$mysql_username,$mysql_password,$mysql_database);
Copyright © 2007 Ternstyle Inc., All rights reserved.
Site designed by, well, me.