Who wants some rep?

Discussion in 'PHP' started by aaron_nimocks, Jul 17, 2006.

  1. #1
    Ok I need help because I am tired of trying to figure this out. Im trying to put an RSS feed into a directory script. It worked fine with Java but now I want to switch to PHP so its search engine readable.

    Heres the code I am working with. The {$keywords} part displays what it wants to see. Say if I remove that part and put "display%2Bcorrectly$2Bdamnit!" it would work. But if {$keywords} = display%2Bcorrectly$2Bdamnit! it wont work even though it did when I did the exact same thing in the Java version.

    Any help that gets me to my answer will be rewarded with some rep. :)

    www.swaplinks.us if you want to see what I mean. Right above the RSS feed box I have {$keywords} displayed.

    *it may appear to be working - Thats because I am using the javascript code until I figure out how to work the php.

    {php}
    $olderror_reporting =error_reporting(0);
    include ("http://www.swaplinks.us/RSSCB2/rss.php?url=http%3A%2F%2Fnews.google.com%2Fnews%3Fhl%3Den%26ned%3Dus%26q%3D{$keywords}%26ie%3DUTF-8%26output%3Drss&newpage=&chead=&atl=&desc=&owncss=&eleminate=&auth=&dts=&width=600&max=5&maxfrom=5&maxto=10&tlen=0&rnd=1&bt=2&bs=Solid&nmb=1&ntb=1&naf=1&nst=1&nwd=0&nht=0&initime=1153184378&dlttime=0&dlen=0&bg=%23FFFFFF&bc=%23FF6600&tc=BLACK&ts=8&spc=1&ims=&lc=BLUE&lstyle=-1&rel=1&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_VARS['PHP_SELF']."&phpout=1");
    error_reporting($olderror_reporting);
    {/php}
    PHP:

     
    aaron_nimocks, Jul 17, 2006 IP
  2. Boby

    Boby Peon

    Messages:
    207
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What if you use this?
    $url = urldecode ("http://www.swaplinks.us/RSSCB2/rss.php?url=http%3A%2F%2Fnews.google.com%2Fnews%3Fhl%3Den%26ned%3Dus%26q%3D{$keywords}%26ie%3DUTF-8%26output%3Drss&newpage=&chead=&atl=&desc=&owncss=&eleminate=&auth=&dts=&width=600&max=5&maxfrom=5&maxto=10&tlen=0&rnd=1&bt=2&bs=Solid&nmb=1&ntb=1&naf=1&nst=1&nwd=0&nht=0&initime=1153184378&dlttime=0&dlen=0&bg=%23FFFFFF&bc=%23FF6600&tc=BLACK&ts=8&spc=1&ims=&lc=BLUE&lstyle=-1&rel=1&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_VARS['PHP_SELF']."&phpout=1");
    include "{$url}";
    PHP:
    I have not tested it, just a suggestion to get rid of the %3A%2F%2 chars.

    Boby
     
    Boby, Jul 17, 2006 IP
  3. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #3
    Ahh it really hates that code. :)

    Think the only problem is that it isnt reading what the variable {$keywords} is. This is using the esyndicat directory script in a .tpl file. Basically same thing as phpld if you ever messed with that.
     
    aaron_nimocks, Jul 17, 2006 IP
  4. Boby

    Boby Peon

    Messages:
    207
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you sure $keywords is not empty and is accessible?

    Try it out with a simple:
    echo $keywords;
    PHP:
    Do you see some output?
     
    Boby, Jul 17, 2006 IP
  5. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #5
    It wont work like that.

    Its {$keywords} not $keywords. Thats how they define the variable in the smarty library for this directory script.
     
    aaron_nimocks, Jul 17, 2006 IP
  6. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Actually, Boby was heading in the right direction. Smarty wants to replace the variable $keywords with its value. In order to do so, Smarty must know the value of $keywords.

    Check to make sure it is either created in the function which outputs the page or is available as a global variable in that function: global $keywords;

    I would isolate that section of the script and put the statement:

    echo $keywords . "br>";

    to make sure the value is what you expect.

    It may also be that php is trying to substitute a variable for the bit after the dollar sign. Making sure the dollar sign is escaped -- \$ -- will prevent that.
     
    clancey, Jul 17, 2006 IP
  7. Boby

    Boby Peon

    Messages:
    207
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    {$keywords} is (or can be) a template variable for Smarty. It should be declared in your PHP file.

    But when you are using PHP code, you will use $keywords.
    There is another thing...you can use {$keywords} as a delimiter for your variable. I give you 3 examples that are all correct and have the same output:
    echo "These are my {$keywords}";
    echo "These are my $keywords";
    echo "These are my ".$keywords;
    PHP:
    In this case, either if you use this in you PHP files or in a Smarty template file between the {php} ... {/php} tags, it's no more a template variable.

    One question, how are you populating you keywords variable and where?

    Boby
     
    Boby, Jul 17, 2006 IP
    GTech likes this.
  8. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #8
    Ok I got ya.

    {php}
    1. echo "These are my {$keywords}";
    2. echo "These are my $keywords";
    3. echo "These are my ".$keywords;
    {/php}

    Neither of these give me an output. But if I just do {$keywords} all alone it does.

    I populate the variable when I enter the meta keywords for the link or category when I add it.

    Thans for sticking with me so far trying to figure this out. :)
     
    aaron_nimocks, Jul 18, 2006 IP
  9. petronel

    petronel Peon

    Messages:
    113
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    you can try something like this:
    
    {include file="http://www.swaplinks.us/RSSCB2/rss.php?url=http%3A%2F%2Fnews.google.com%2Fnews%3Fhl%3Den%26ned%3Dus%26q%3D$keywords%26ie%3DUTF-8%26output%3Drss&newpage=&chead=&atl=&desc=&owncss=&eleminate=&auth=&dts=&width=600&max=5&maxfrom=5&maxto=10&tlen=0&rnd=1&bt=2&bs=Solid&nmb=1&ntb=1&naf=1&nst=1&nwd=0&nht=0&initime=1153184378&dlttime=0&dlen=0&bg=%23FFFFFF&bc=%23FF6600&tc=BLACK&ts=8&spc=1&ims=&lc=BLUE&lstyle=-1&rel=1&tfont=Verdana,+Arial,+Sans-serif&rf="}
    
    PHP:
    using {php} inside a smarty template is not a good ideea.

    PS: at the end of that include you should look for smarty variant of SERVER_NAME and PHP_SELF
     
    petronel, Jul 18, 2006 IP
  10. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #10
    None of this is working. Still looking. :(
     
    aaron_nimocks, Jul 18, 2006 IP
  11. petronel

    petronel Peon

    Messages:
    113
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #11
    i supose that part is inside some <script tag..
    why don't you use
    src="http://www.swaplinks.us/RSSCB2/rss.php?url=http%3A%2F%2Fnew............{$keyword}."
    
    Code (markup):
    can you past a bit more of code (few lines before and after)?
     
    petronel, Jul 18, 2006 IP
  12. petronel

    petronel Peon

    Messages:
    113
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i just fixed that problem without using {php} codes inside smarty
     
    petronel, Jul 18, 2006 IP
    MiloJones and aaron_nimocks like this.
  13. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #13
    Yes Petronel fixed my problem. I let him FTP into my site and it was fixed within 10 minutes. Very trustworthy and quick! :)
     
    aaron_nimocks, Jul 18, 2006 IP