#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    17
    Rep Power
    0

    Parse error within class


    Ok.. so I'm basically creating a php class. Note although it's called "RSS" it is not compliant as I am tweaking it for my own purposes. But I am getting the error
    "syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in mypath/RSS.class.php on line 4"

    Here is rss.class.php:
    Code:
       <?
      class RSS{
      
    	public function RSS()    //Here is error
    	{
    		require_once('mysql_connect.php');
    	}
    
    	public function GetFeed(){
    		return $this->getDetails();
    	}
    
    	private function dbConnect()
    	{
    		DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
    	}
    
    	private function getDetails()
    	{
    		$detailsTable = "user_quotes";
    		$this->dbConnect($detailsTable);
    		$query = "SELECT * FROM ". $detailsTable;
    		$result = mysql_db_query (DB_NAME, $query, LINK);
    
    		while($row = mysql_fetch_array($result))
    		{
    			$details = '<quote>
    					<quote_text>'. $row['quote'] .'</quote_text>
    					<author>'. $row['author'] .'</author>
    					<yes>'. $row['yes'] .'</yes>
    					<no>'. $row['no'] .'</no>
    					<submitter>'. $row['submitter'] .'</submitter>
    				    </quote>';
    		}
    		return $details;
    	}
    
    }
    ?>
    I am using the class like this in another file:
    Code:
    <?
     // header("Content-Type: application/xml; charset=ISO-8859-1");
     // echo xml stuff required by tbxml
      include("RSS.class.php");
      echo '<?xml version="1.0"?>';
      echo '<quotes>';
      $rss = new RSS();
      echo $rss->GetFeed();
      echo '</quotes>';
    ?>
    my mysql connect (minus key info) looks like this:
    Code:
    <?
      DEFINE ('DB_USER', 'myusername');
      DEFINE ('DB_PASSWORD', 'mypass');
      DEFINE ('DB_HOST', 'localhost');
      DEFINE ('DB_NAME', 'mydbname');
    
      // Make the connnection and then select the database.
      $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
      mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
    ?>
    Any ideas? I can't seem to see it
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,884
    Rep Power
    6356
    What version of PHP are you using? It seems right to me. Just to be sure, change the function's name from RSS to __construct (two underscores)

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1171
    Originally Posted by ManiacDan
    What version of PHP are you using? It seems right to me. Just to be sure, change the function's name from RSS to __construct
    I was thinking the same thing, somehow the old-style constructor was failing, but it's just as likely the OP is using an older version that doesn't support access specifiers and the 'public' is causing it to fail.

    The class file alone, and a script to include it work fine for me.

    Comments on this post

    • ManiacDan agrees : I love that you STILL have my quote in your sig.
    "Seriously, we're not a search engine, we're actual people." ~ ManiacDan

    BookMooch.com : Give books away. Get books you want.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,884
    Rep Power
    6356
    The class file alone, and a script to include it work fine for me.
    Right, me too.

    OP, if you're not using PHP5, upgrade now. Then you'll have access to the [PHPNET="simplexml_load_string"]simplexml_load_string[/PHPNET] function, which will parse RSS feeds.

    There are plenty of open-source PHP classes that will MAKE RSS feeds too.

    -Dan

    Comments on this post

    • lnxgeek agrees : Exactly. Reinvent the wheel as little as possible.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    17
    Rep Power
    0
    ah yes I seem to be running 4.4.4 I'll upgrade and report back!

    And check out those sweet RSS links you have me thanks

IMN logo majestic logo threadwatch logo seochat tools logo