Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    small string problem

    Hi. I am trying to parse a list of RSS links through an RSS aggregator. The links are stored in a text file like this...

    Code:
    http://cyber.law.harvard.edu/rss/examples/rss2sample.xml
    http://www.utilitycomputing.com/news/topten.xml
    ...
    ...
    ... the value of $currentLine when echoed gived the exact value of the RSS url, however the following line produces a "Error: RSS file not found" error...

    Code:
    if ($rs = $rss->get('$currentLine')){

    If however I replace this line with the following, it works fine...

    Code:
    if ($rs = $rss->get('http://www.utilitycomputing.com/news/topten.xml')){
    Code:
    $feedlist = fopen("feedList.txt","r");
    rewind($feedlist);							
    while (!feof($feedlist)) {
    	$currentLine = fgets($feedlist);
    	echo $currentLine."<br>";
    	if ($rs = $rss->get('$currentLine')){										
    		// Title
    		echo "<h4><b><a href='$rs[link]'>$rs[title]</a></b></h4><br>";
    		// Description
    		echo "$rs[description]<br><br>";
    	}else {
    		die ('Error: RSS file not found...');
    	}							
    }

    Is there a reason for this? because as far as I can see, this should work

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Variables in single quotes aren't parsed, so it's looking for a file called $currentLine. So, remove the quotes or use double-quotes.


  •  

    Posting Permissions

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