Just a very basic, solid mysql connection class:
<?php
class DBMysqlConnection
{ //v1.0 auto-connection on initiation
var $host, $dbname, $username, $handle, $error;
function DBMysqlConnection($IN_host, $IN_dbname,
$IN_username, $IN_password)
{
$this->host = $IN_host;
$this->dbname = $IN_dbname;
$this->username = $IN_username;
$this->handle = mysql_connect($IN_host, $IN_username,
$IN_password);
if ($this->handle == false) $this->error =
mysql_error();
else
{
if ( mysql_select_db($IN_dbname, $this->handle) ==
false) $this->error = mysql_error();
}
$this->CheckError();
}
function Disconnect()
{
if ( mysql_close($this->handle) == false)
$this->error = mysql_error();
$this->CheckError();
}
function CheckError()
{
if (!empty($this->error))
die('<b>DBMysqlConnection fatal error:</b><br
/>'.$this->error);
}
}
$DBM = new
DBMysqlConnection('localhost','test','root','geheim');
//$DBM->handle
$DBM->Disconnect();
?>
----
Server IP: 83.137.20.120
Probable Submitter: 212.238.243.110
----
Manual Page -- http://www.php.net/manual/en/function.mysql-connect.php
a>
Edit -- http://master.php.net/manage/user-notes.php?action=
edit+61668
Delete: added to the manual -- htt
p://master.php.net/manage/user-notes.php?action=delete+61668
&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.
php.net/manage/user-notes.php?action=delete+61668&report
=yes&reason=bad+code
Delete: spam -- http://master.php.
net/manage/user-notes.php?action=delete+61668&report=yes
&reason=spam
Delete: useless -- http://master.p
hp.net/manage/user-notes.php?action=delete+61668&report=
yes&reason=useless
Delete: non-english -- http://mast
er.php.net/manage/user-notes.php?action=delete+61668&rep
ort=yes&reason=non-english
Delete: already in docs -- http://
master.php.net/manage/user-notes.php?action=delete+61668&
;report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-
notes.php?action=delete+61668&report=yes
Reject -- http://master.php.net/manage/user-
notes.php?action=reject+61668&report=yes
Search -- http://ma
ster.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|