TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-16-2009, 09:16 PM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default Doh!

Fatal error: Call to a member function executeQuery() on a non-object in /home/phpsauce/public_html/sources/authClass.php on line 65

PHP Code:
    function checkSession() {
        @
session_start();
        
$username $_SESSION['username'];
         
$session session_id();
        
$ip $_SERVER['REMOTE_ADDR'];
        
$query "SELECT * FROM users WHERE (username = '$username') AND (session = '$session') AND (ip = '$ip')";
        
$result $connect->executeQuery($query) or die('Auth Subsystem Error');

        if (
mysqli_num_rows($result) > ) {
            return 
true;
        } else {
            
$this->session_defaults();
            return 
false;
        }
    } 
Line 65:
PHP Code:
$result $connect->executeQuery($query) or die('Auth Subsystem Error'); 
What am I doing wrong?
Sam Granger is offline  
Reply With Quote
Old 04-16-2009, 09:19 PM   #2 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default

And if it helps, here is the executeQuery code:

PHP Code:
    public function executeQuery($query) {
        if(
$res mysqli_query($this->link,$query)) {
            return 
$res;
        }
        else {
            
$this->dbError mysqli_error($this->link);
            return 
false;
        }
    } 
Sam Granger is offline  
Reply With Quote
Old 04-16-2009, 09:19 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The variable $connect (local to the scope of that function) is not defined and undefined variables don't have methods attached. Which class has an executeQuery method and where is it instantiated?

Edit: Are these both defined in the same class?
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Sam Granger (04-16-2009)
Old 04-16-2009, 09:27 PM   #4 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default

Thanks for your fast reply :)

PHP Code:
    function __construct() {
        @
session_start();
        require_once( 
SOURCES_PATH 'dbClass.php' );
        
$connect = new dbClass();
        
$connect->dbConnect'localhost''user''pass''database' );

        @
session_start();

        if (!isset(
$_SESSION['logged'])) {
            
$this->session_defaults();  
        }

    } 
This is from the authClass. dbClass contains the executeQuery function.
Sam Granger is offline  
Reply With Quote
Old 04-16-2009, 10:33 PM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The $connect variable is only available within the __construct. The simplest workaround would be to use $this->connect wherever you have just $connect right now.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Sam Granger (04-16-2009)
Old 04-16-2009, 10:44 PM   #6 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
The $connect variable is only available within the __construct. The simplest workaround would be to use $this->connect wherever you have just $connect right now.
Ah! Starting to understand OOP a bit better now, thanks Salathe!
Sam Granger is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


All times are GMT. The time now is 04:41 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design