SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question I keep getting a parse error with the MySQL class from PHP Anth book

    HI,
    I just cannot find what I'm doing wrong with the class, maybe someone can help me. I kep getting a error message : Parse error: syntax error, unexpected T_OBJECT_OPERATOR on the line with the follwing code :
    PHP Code:
    this->mysql = &$mysql
    Can someone help me? here the complete class :

    PHP Code:
    class MySQLResult {

        var 
    $mysql;      //Instance of MySQL providing database connection
        
    var $query;      //Query Resource

        /**
         * MySQLResult constructor
         */
        
    function MySQLResult(&$mysql$query)
        {
            
    this->mysql = &$mysql;
            
    this->query $query;
        }

        
    /**
         *Fetches a row from the result
         */
        
    function fetch()
        {
            if(
    $row mysql_fetch_array($this->queryMYSQL_ASSOC)) {
                return 
    $row;
            } else if (
    $this->size() > 0) {
                
    mysql_data_seek($this->query,0);
                return 
    false;
            } else {
                return 
    false;
            }
        }

        
    /**
         * Return the number of rows selected
         */
        
    function size()
        {
            return 
    mysql_num_rows($this->query);
        }
        
        
    /**
         * Return the number Of Affected Row
         */
         
    function affected()
         {
            return 
    mysql_affected_rows($this->mysql->dbConn);
         }
        
        
    /**
         * Return the Id ofthe last inserted row
         */
        
    function insertID()
        {
            return 
    mysql_insert_id($this->mysql->dbConn)
        }

        
    /**
         * Check for MySQL errors
         */
        
    function isError()
        {
            return %
    this->mysql->isError();
        }


  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of PHP are you running?

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is PHP 5

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to fix everywhere you use "this->" to be "$this->".

    Not an Advanced Forum topic.
    Christopher

  5. #5
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank!!! It's now working!!!!

  6. #6
    Compulsive Clubber icky_bu's Avatar
    Join Date
    Aug 2003
    Location
    Portugal
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you must be very carefull using the code from the book. There are a couple typos here and there, so use it as a guidline, but use your judgement and knowledge to find the (very few) mistakes

    I'm also reading the books and find them insightful, although some parts jump too far ahead for newbies to grasp the context. But this is another story...

    Good luck and good work!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •