Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    427

    php include - Going Nuts

    I have been trying to figure this out for over two hours.

    Code:
    $searchvalue = ($folder);
    $FeedOneURL = "/page.php?page=$searchvalue&format=rss";
    Above is a portion of code I have in my config file. If I echo $FeedOneURL it wont work. However, if I take that $FeedOneURL line and place it directly in the web page, it "WILL" work. I can't work out why! What difference does it make if the variable is in the page or in the config?

    I have made sure that config.php is included in the page. I have also made sure that I am trying to echo after the config include. But it wont work no matter what! I think I might have the formatting wrong.

    I tried this, but it wont work either:

    Code:
    $FeedOneURL = "/page.php?page=.'$searchvalue'.&format=rss";
    Please give me a suggestion. I am really stumped here. Why wont it work??

    How on earth should it make a difference whether or not I have that $FeedOneURL line in the config or in the actual page where I am echoing it? It's the same thing! So long as I ahve included the config on the page before I try to echo, it should fricken echo! right?

    I'm lost. Please help. I'm going nuts.

  2. #2
    First, you did something wrong and it's hard to say what without looking at your config file. But, the portion of the code you've sent..something's weird. First:

    PHP Code:
    $searchvalue = ($folder); // why do you use braces? remove them
    $FeedOneURL "/page.php?page=$searchvalue&format=rss"
    First thing that comes to my mind is - where is $folder variable set? It seems like it's empty. Another thing, since I can't see the config file - you might be overwriting your $FeedOneURL somewhere.

    So..post the entire config (hide passwords and such) and we'll examine it.
    Dyslexics Have More Fnu

  3. #3
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    427
    Ok (thanks for rsponding), I will remove the braces and see how I go. I paraphrased the code to save confusion. But here's the actual config file and the actual page I am working on:

    Code:
    <?php
    $theme = "Breaking News";
    $googleID = "lalalalala";
    $ebayID = "lalalalala";
    
    
    //===========NO NEED TO EDIT BELOW HERE
    
    $HomepageSearchTerm = ($theme);
    $HomepageSearchTerm = ereg_replace(' ', '-', $HomepageSearchTerm);
    $HomepageSearchTerm = strtolower($HomepageSearchTerm);
    
    $EbayIndexSearchTerm = ($HomepageSearchTerm);
    
    $folder = ($_SERVER['PHP_SELF']);
    $folder = ereg_replace('/', '', $folder);
    $folder = ereg_replace('.php', '', $folder);
    $folder = ereg_replace('index', '', $folder);
    $folder = strtolower($folder);
    
    $searchvalue = ($folder);
    
    $keyword = $_GET['page'];
    $keyword = ereg_replace('-', ' ', $keyword);
    $keyword = ucwords(strtoupper($keyword)); 
    $keyword = ucwords($keyword); 
    $keyword = ucwords(strtolower($keyword));
    
    $searchvaluesection = $_GET['page'];
    
    $pagetitle = ($_SERVER['PHP_SELF']);
    $pagetitle = ereg_replace('-', ' ', $pagetitle);
    $pagetitle = ereg_replace('/', '', $pagetitle);
    $pagetitle = ereg_replace('.php', '', $pagetitle);
    $pagetitle = ereg_replace('index', '', $pagetitle);
    $pagetitle = ucwords(strtoupper($pagetitle)); 
    $pagetitle = ucwords($pagetitle); 
    $pagetitle = ucwords(strtolower($pagetitle));
    
    $sectiontitle = $_GET['page'];
    $sectiontitle = ereg_replace('-', ' ', $sectiontitle);
    $sectiontitle = ucwords(strtoupper($sectiontitle)); 
    $sectiontitle = ucwords($sectiontitle); 
    $sectiontitle = ucwords(strtolower($sectiontitle));
    ?>
    Code:
    		<table cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr>
            <td width="20%" valign="top" class="leftmenu">
    				  <div class="lmtop"><a href="/">Home</a></div>
              <?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/keyword-display-index.php') ?>
            </td>
            <td width="50%" valign="top" class="left-column">
              <div class="h3div">
    					  <h3 style="display: inline;"><?php echo $theme ;?></h3>
    					</div>
    					
    					<div class="ctext">
    					<?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/text/homepage.php') ?>
              </div>
    
              <div class="breadcrumb">
                <a href="/">Home</a> | <a href="#FeedOne"><?php echo $FeedOne ;?> Results</a> &gt; <a href="#FeedTwo"><?php echo $FeedTwo ;?> Results</a>
              </div>
    					<?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/google-advertisement.php') ?>
    					<?php 
              <?
    
    					$google = ($FeedOneURL); 
    					$FeedOneURL = "http://news.google.com/news?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-44,GGLG:en&tab=wn&q=$searchvalue&output=rss"; 
    					include($_SERVER['DOCUMENT_ROOT'] . '/inc/google-parser.php');
    					?>
            </td>
    
            <td valign="top" class="right-column">
            <?php 
    				include($_SERVER['DOCUMENT_ROOT'] . '/inc/auction-search.php');
    				$FeedTwoURL = "http://beta.search.msn.com/news/results.aspx?q=$searchvalue&format=rss";
    				$msn = ($FeedTwoURL); 
    				include($_SERVER['DOCUMENT_ROOT'] . '/inc/msn-parser.php') ?></td>
          </tr>
        </table>

    Could it be because I used $searchvalue twice? I don't think that should make a difference tough. I am really going nuts here.

    See, the variable WORKS when I put in "in the page", but if I take it out of the page and put it in the config file (amd thing), it wont work. It doesn't make sense. It should work either way, because they are both the same thing.

  4. #4
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    427
    Oh...

    Code:
    $google = ($FeedOneURL); 
    $FeedOneURL = "http://news.google.com/news?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-44,GGLG:en&tab=wn&q=$searchvalue&output=rss";
    This code is actually the other way around. It doesn't work that way. But that's not a part of the problem. It just wound up like that when I was shuffling things around. Just imagine those two lines are vice-versa.

  5. #5
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    427
    For the time being, I have found a solution. It's really scary stuff, but it works. I have taken $FeedOneURL and $FeedTwoURL and saved them as feedoneurl.php and feedtwourl.php -- then I am calling them into the page where they are supposed to go with includes.

    See, that's ally really wanted to do, because I have these feeds on 3 different section of the website. I am making an admin area where I can specify the feed URL that I want to use, so that I am not limited to google and msn.

    So, in the admin, there will now be a text box where I can paste a dynamic RSS URL. All I will have to do is paste the RSS URL into the text box and replace the search string, like tom+cruise with $searchvalue, and it should work.

    I STILL don't know why the above wont work, but I suppose the two includes will do. I will have to make an area in the admin where I can write to those files to replace the RSS URL.

  6. #6
    Join Date
    Oct 2004
    Location
    UK
    Posts
    487
    Why do you need to declare the variable as $FeedTwoURL, and then redeclare as $msn?

    Try this:

    PHP Code:
    $msn "http://beta.search.msn.com/news/results.aspx?q=" urlencode($searchvalue) . "&format=rss"
    And use the same principal on the google link.

Posting Permissions

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