MySQL connect Function and Close to use on a class.

4 views
Skip to first unread message

roja...@gmail.com

unread,
Dec 27, 2007, 4:13:41 PM12/27/07
to Connecticut PHP Developers Group - CPDG
This will save you time on coding a DB connection. This is to use on a
class.


--------------------------/
Connection /------------------------------------------------------




function db_connection($host,$user,$pass,$data){

$conn = @mysql_connect($host,$user,$pass);
if(!$conn){
$error = TRUE;
} else {
$error = FALSE;
mysql_select_db($data,$conn);
}//mysql end
return ($error);
$this->close = $conn;
}//Function db_connect close tag


-------------------------------------------------------------------------------------------------------


And here is the the close

---------------------------------/
Close /--------------------------------------------------------


function db_close(){
@mysql_close($this->close);
}//Function db_close close tag



-------------------------------------------------------------------------------------------------


NOTE: Only to use on a Class.
Reply all
Reply to author
Forward
0 new messages