note 61448 added to ref.mysql
| From: | elliotthird at tiscali dot co dot uk | Date: | Fri, 03 Feb 2006 16:04:08 +0000 |
| Subject: | note 61448 added to ref.mysql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102935@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 85.116.0.130
Probable Submitter: 80.41.210.242
----
Manual Page -- http://www.php.net/manual/en/ref.mysql.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61448
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61448&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61448&report=yes
Search -- http://master.php.net/manage/user-notes.php