Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error: Call to a member function addActiveGuest() on a non-object in
Old 05-04-2009, 08:53 PM Fatal error: Call to a member function addActiveGuest() on a non-object in
Skilled Talker

Posts: 90
Name: Dominic
Location: Columbus, Ohio
Trades: 0
I keep getting this error:


Fatal error: Call to a member function addActiveGuest() on a non-object in /home/XXXX/domains/XXXX/public_html/home/include/session.php on line 58

Line 55 to 59:


PHP Code:
if(!$this->logged_in){
         
$this->username $_SESSION['username'] = GUEST_NAME;
         
$this->userlevel GUEST_LEVEL;
         
$database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
      } 
__________________
Hi Mom
Hi Dad
dominic95 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-04-2009, 10:49 PM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Can you post the code where $database is set?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 05-05-2009, 01:36 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
Skilled Talker

Posts: 90
Name: Dominic
Location: Columbus, Ohio
Trades: 0
Okay, I fixed that problem I think. But created a new one. I was told by someone that "now you just have an object that isnt correctly instantiated on line 7"

Because I got this error

PHP Code:
Fatal errorCall to a member function query() on a non-object in /home/dominic/domains/ohio-host.com/public_html/home/index.php on line 7 
Line 1 to 13:

PHP Code:
<?php
include './u&ainclude/mainlayout.php';

function 
displayNews(){
   global 
$database;
   
$q "SELECT name,subname,date,type,content FROM ".TBL_NEWS." ORDER BY date DESC,date";
   
$result $database->query($q);
   
/* Error occurred, return given name by default */
   
$num_rows mysql_query($result);
   if(!
$result || ($num_rows 0)){
      echo 
"Error displaying info";
      return;
   }
__________________
Hi Mom
Hi Dad
dominic95 is offline
Reply With Quote
View Public Profile
 
Old 05-05-2009, 03:27 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
$database->query() is not defined. Check that query() has been set somewhere.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 05-05-2009, 09:26 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
Skilled Talker

Posts: 90
Name: Dominic
Location: Columbus, Ohio
Trades: 0
Well, what do you mean? Like so I should put query() somewhere?
__________________
Hi Mom
Hi Dad
dominic95 is offline
Reply With Quote
View Public Profile
 
Old 05-05-2009, 11:22 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Call to a member function on a non-object means that $database is not an object. Most likely this means that $database is not being initialized.

Where is $database being set?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 05-05-2009, 02:28 PM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
Skilled Talker

Posts: 90
Name: Dominic
Location: Columbus, Ohio
Trades: 0
I'm very illiterate when it comes to PHP. Would it help if I packed up the script it sent it to you? Because this is very confusing for me.
__________________
Hi Mom
Hi Dad
dominic95 is offline
Reply With Quote
View Public Profile
 
Old 05-08-2009, 04:42 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
markAtRitetek's Avatar
Experienced Talker

Posts: 32
Name: Mark Hudson
Location: Atlanta, GA
Trades: 0
What it means is that somewhere in your code before that function gets called you need to have a line that looks something like...

$database = new DatabaseClassName('param1', 'param2', 'etc');

The database class name would be whatever class is your database class, and the parameters may or may not be required. Basically you are not initializing/instantiating the $database variable before calling that function.
__________________
Mark Hudson
Ritetek Design

Please login or register to view this content. Registration is FREE
markAtRitetek is offline
Reply With Quote
View Public Profile Visit markAtRitetek's homepage!
 
Old 01-22-2010, 08:22 AM Re: Fatal error: Call to a member function addActiveGuest() on a non-object in
Junior Talker

Posts: 1
Name: why
Trades: 0
NullPointer, markAtRitetek or someone else how can help me is it possible that you can look at my code.. i have a similar problem en i'm not that good in php?

PHP Code:
    <?php
    
                
// Check to see if we have been sent from update.php
                // If so, alert that an update was successful            
                
if(isset($_GET['message'])){
                    echo 
"<p><font color='red'>Wijzigingen opgeslagen</font></p>";
                }
    
        require(
"connection.php");
            
// Load in the content of the current viewing page from the MySQL database
            
$page = (isset($_GET['page'])) ? $_GET['page'] : "1";
            
$sql "SELECT id, content FROM pages WHERE id='$page'";
            
$result $conn->query($sql) or die(mysqli_error());
            if(
$result){
                
$row $result->fetch_object();
                echo 
'<form method="post" action="update.php">';
                echo 
'<input type"hidden" name="id" value="' $row->id '" />';
                echo 
'<textarea name="content" cols="70" rows="20">';
                echo 
$row->content;
                echo 
'</textarea>';
                echo 
'<input type="submit" name="editContent" value="Opslaan" />';
                echo 
'</form>';
            }
    
    
?>
    </div><!--editor-->
    <div id="webpag">
    <ul>
    <?php
                
// Display all the pages that we can edit
                
$sql "SELECT id, name FROM nav";
                
$result $conn->query($sql) or die(mysqli_error());
                if(
$result){
                    while(
$row $result->fetch_object()){
                        echo 
"<li><a href='webpag_updaten.php?page={$row->id}'>{$row->name}</a></li>";                    
                    }
                }
    
?>
Monkkey is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error: Call to a member function addActiveGuest() on a non-object in
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33157 seconds with 12 queries