database class
| From: | Fedde van Feggelen | Date: | Wed, 21 May 2003 20:40:20 +0000 |
| Subject: | database class | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27948@lists.php.net to get a copy of this message | ||
HI,
Not really a db problem, but has something to do with a dbase
I'm tryin to make a database class, but every time i make a class, and execute the file i get:
Parse error: parse error, expecting
T_OLD_FUNCTION' or T_FUNCTION' or T_VAR' or '}'' in /home/new.php on line 4
I have one working class but another just wont work...
The not working one (simplyfied)
<?php
class Dbase {
function connection() {
echo"connect";
}
}
?>
--------
<?php
include ("dbase.php");
$test = new Dbase;
$test->connection();
?>
The code i made which works:
class Database {
function Database($host, $database, $username, $password) {
$this->host = $host;
$this->database = $database;
$this->username = $username;
$this->password = $password;
}
function connect() {
$this->db = mysql_connect($this->host, $this->username, $this->password);
if ($this->db == false) {
return FALSE;
} else {
return TRUE;
}
}
}
// Make the object
$db = new Database("localhost", "dbase", "user", "pass");
$db->connect();
what am i doing wrong? Cuz i really dont understand this.. really freaking me out
Tnx in Advance
Fedde