1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development PHP Help

Discussion in 'Software' started by dfhaii, 3 Jan 2005.

  1. dfhaii

    dfhaii internets

    Joined:
    24 Mar 2002
    Posts:
    520
    Likes Received:
    0
    I am halfway through making a MySQL class to interface with the db and be shiny and stuff but i am unable to understand an error i get.

    PHP:
    class mysqlClass{
        var 
    $queryres;        #used to return the results of a query
        
    var $result;        #used to store the results of a query
        
    var $numrows;       #used to store the number of rows
        
    var $connection;    #used as a connection reference 
        
        
    function mysqlClass($details){
            
    $this->user['host'] = $details['host'];
            
    $this->user['user'] = $details['user'];
            
    $this->user['pass'] = $details['pass'];
            
    $this->user['db'] =   $details['db'];        

            
    $this->connection = @mysql_connect($this->user['host'], $this->user['user'], $this->user['pass']) || die("Connect error"); #connect to mySQL
            
    $this->selectDatabase($this->user['db'], $this->connection);    #select appropriate db
            
        
    }

        function 
    selectDatabase($database){
            @
    mysql_select_db($database) || die ("Db select error");
        }

        function 
    closeConnection(){
                    
    mysql_close($this->connection);
        }

             
    //more functions here.
                
            
    }
    If i use that to make an object like $conn = new mysqlClass($array); it connects, and selects the database fine. If i then call $conn->closeConnection(); i get the error Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource, and cannot understand why.

    Any help would be usefull
    Col
     
  2. Hwulex

    Hwulex New Member

    Joined:
    1 Feb 2002
    Posts:
    4,007
    Likes Received:
    1
    lol, thought this looked a bit familiar. :idea:

    Have already replied on Xaprief. :)


    PS - Someone else that uses #comments - woo. Don't seem to see many of them. :D
     

Share This Page