Leave out the second $.

Eg, $this->database is correct.

Next time when debugging, set error_reporting(E_ALL);
This will catch this error I believe.

Bye, John

Alexander Czernay <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I just tried to write a simple class for opening a MySQL-database with
PHP.
> The database get's opened, but the handle isn't transfered back. I can
then
> use the database, but only if I don't specify the handle in mysql_query.
>
> Any ideas?
>
> Code:
> db.php:
> <?
> class Database {
>  var $connect;
>  var $database;
>
>  function Database($host="local") {
>   switch ($host) {
>    case "local" :
>     $this->$connect = mySQL_connect("host","user","pass");
>     $this->$database = mysql_select_db("db", $this->$connect);
>     break;
>   }
>  }
>
>  function getConnect() {
>   return $this->$connect;
>  }
>
>  function getDatabase() {
>   return $this->$database;
>  }
> }
> ?>
>
> test.php:
> <html>
> <head>
> </head>
>
> <body>
>
> <?
> include("lib/db.php");
>
> $db = new Database();
> $connect = $db->$getConnect;
>
> $result = mysql_query("select * from data");
> while ($data = mysql_fetch_array($result)) {
>  extract($data);
>  echo "-".$id."-<br>";
> }
>
>
> ?>
>
> </body>
> </html>
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to