note 61448 deleted from ref.mysql by betz
| From: | betz@php.net | Date: | Sun, 05 Feb 2006 12:38:35 +0000 |
| Subject: | note 61448 deleted from ref.mysql by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-103027@lists.php.net to get a copy of this message | ||
Note Submitter: elliotthird at tiscali dot co dot uk
----
Here's a useful database class:
<?php
class database {
function database($server, $username, $password, $database) {
$this->connection = mysql_connect($server, $username, $password);
if (!$this->connection || !mysql_select_db($database, $this->connection)) {
return false;
} else {
return true;
}
}
function query($sql, $type = MYSQL_BOTH) {
$query = mysql_query($sql, $this->connection);
while ($row = mysql_fetch_row($query)) {
$return[] = $row;
}
return $return;
}
}
/* Change this to reflect your database setup */
$database = new database('localhost', 'root', '',
'forum');
if (!$database) {
$error = 'Could not connect to the database!';
include 'error.tpl';
exit;
}
?>
Just contact me via my email with ANY questions, comments etc.