View Single Post
Old 08-08-2007   #2 (permalink)
The Eagle
Moderator
 
Join Date: Jul 2004
Location: Quebec City, Canada
Posts: 50

When you write a member function in PHP, you cannot implicitly access the objet's scope. Instead, you have to explicitly refer to the variables using $this. Try this and see if it works better:


PHP Code:
<?

class mysql
{
    var 
$connection;

    function 
Connect($dbhost$dbuser$dbpass$dbname)
    {
        
$this->connection mysql_connect($dbhost$dbuser$dbpass);
        
mysql_select_db($dbname$this->connection);
    }
    
    function 
Close()
    {
        
mysql_close($this->connection);
    }
    
    function 
Query($sql)
    {
        
$query mysql_query($sql) or die(mysql_error());
        return 
$query;
    }
    
    function 
GetNum($query)
    {
          
$num mysql_num_rows($query);
          return 
$num;
    }
 
    function 
Fetch($query)
    {
          
$array mysql_fetch_array($query);
          return 
$array;
    }
}

?>
The Eagle is offline