TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   uhum??? (http://www.talkphp.com/advanced-php-programming/1507-uhum.html)

Tanax 11-21-2007 12:42 PM

uhum???
 
Quote:

Warning: Attempt to assign property of non-object in C:\wamp\www\DB Class 2\includes\classes.php on line 12
classes.php:
php Code:
<?php

/**
||||||||||||||||||||||||||||||||||||||||||
|||| @author Tanax
|||| @copyright 2007
||||||||||||||||||||||||||||||||||||||||||
**/


    include('classes/TANAXIA.php');
    include('classes/DB.php');
    $tanaxia->database = DB::getInstance($tanaxia['config']['database']['type']);   
    $tanaxia->database->setHandler(
               
                        $tanaxia['config']['database']['host'],
                        $tanaxia['config']['database']['user'],
                        $tanaxia['config']['database']['pass'],
                        $tanaxia['config']['database']['data']
                       
                        )
                        ->connect()
                        ->select();
                       
                       
    $tanaxia->user = TANAXIA::getInstance('user', $tanaxia->database);
   
?>

Ohye, and btw... the $tanaxia variables are declared in config.php.
And classes.php are included in config.php

bluesaga 11-21-2007 12:55 PM

The error means you are trying to set a variable on an object, that isn't an object.

Tanax 11-21-2007 01:00 PM

But, I've used this in DB.php:

php Code:
<?php

/**
||||||||||||||||||||||||||||||||||||||||||
|||| @author Tanax
|||| @copyright 2007
||||||||||||||||||||||||||||||||||||||||||
**/


    function __autoload($database) {
       
        include_once('databases/' . $database . '.php');
       
    }

    class DB {
       
        public static $DB;

        public static function getInstance($type) {
       
            if(!is_object(self::$DB)) {
               
                $type = strtolower($type);
               
                switch($type) {
                   
                    case 'mysql':
                    
                        self::$DB = new DBmysql();
                        break;
                        
                    case 'mssql':
                    
                        self::$DB = new DBmssql();
                        break;
                        
                    default:
                    
                        self::$DB = new DBmysql();
                        break;
                        
                }
               
            }
           
         return self::$DB;
   
        }

    }


?>

So it should create the object for me... :S

Karl 11-21-2007 02:02 PM

I think the error is actually due to the left hand value, that is:

PHP Code:

$tanaxia->database 

Ensure the database property exists inside the $tanaxia object.

Tanax 11-21-2007 02:33 PM

Yeup, got it working :)
Thanks!


All times are GMT. The time now is 11:59 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0