database class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux