Re: Help with DB.php in PHP5

From: Date: Mon, 29 Nov 2004 05:06:13 +0000
Subject: Re: Help with DB.php in PHP5
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203050@lists.php.net to get a copy of this message
Info@Best-It wrote:
I upgraded to PHP 5 and now I am having some problems with DB.php. 2 problems: 1. I get this notice Notice: Undefined property: DB_mysql::$disconnect 2: the $db->query no longer works. I have gone as far as to place this line at the beginning of the file: set_include_path(".:/usr/local/lib/php"); //this is where DB.php resides. I also have QueryTool in the DB directory in this path. Here is my code: function db_connect($sql) {
    global $dsn;
    $db = DB::connect($dsn, TRUE);
    $r = $db->query($sql);
    if(DB::isError($db)){
        die($db->getMessage());
    } else {
        $success = true;
    }//end if
    $s = array();
    $i =0;
    if($success){
        while($data = mysql_fetch_assoc($r->result)){
            $i++;
            array_push($s, $data);
            }
        $i =0;
        $db->disconnect;
    } else {
        die("Query for content failed.");
    }
    return $s;
    }
Thanks for your help! Tim
hi :
    DB::connect MUST be static . such as:
class DB { public static connect(){} public $disconnect; } I think you can only use DB::disconnect to access constant not variable -- -- ShenKong (shenkong@php.net) -- http://www.openphp.cn

« previous php.general (#203050) next »