Page 1 of 1

global classes and their problems

Posted: Wed Jul 23, 2003 2:24 pm
by Austrian Coder
Hi!

I have the file database.php, which contains the class Database. Ans i have an file (global.php), wich looks like this:

<?php
session_start(); // start a new session or take the old one
require_once 'database.php';

// open database
$g_database = new Database();
$g_database->Connect();

?>

Here the test.php:

<?php

#require 'global.php'

$g_database->Function(......);
?>

At this line, $g_database->Function(......);, i get this fatal error: Call to a member function on a non-object in /.../test.php on ...

What i am doing wrong?
Thanks, Austrian Coder

Posted: Wed Jul 23, 2003 2:43 pm
by nielsene
Well the '#' starts the line of a comment so you are never including/requiring 'global.php' in test.php

Posted: Wed Jul 23, 2003 3:14 pm
by Austrian Coder
Thanks... now it works... never code late in the night
Normaly i am a c(++) coder, so the '#'-statement is used often by me