Page 1 of 1

Need help with include files

Posted: Sat Nov 08, 2008 10:11 am
by Radiator251
I know C+ and I'm currently learning PHP. I have an include file that looks like this (it is called feeds.php):

Code: Select all

<?php
    $rss1 = "";
    $rss2 = "";
    $rss3 = "";
    $rss4 = "";
    
    // Economy feeds
    $feed_Economy1          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/economy/index_xml";
    $feed_Economy2          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/government/index_xml";   
    $feed_Economy3          = "http://online.wsj.com/xml/rss/3_7014.xml";   
    $feed_Economy4          = "http://online.wsj.com/xml/rss/3_7086.xml";
?>
And I'm including it in another file using <?php include("feeds.php"); ?> at the top of the file.

However, when I try to call a variable from the include file, nothing happens.

I write, for instance:

Code: Select all

echo $feed_Economy1;
just to see if it works, and nothing shows up. Is there something special I have to do to tell the file where $feed_Economy1 comes from?

-Yes, I have the URL correct for the include.

Thanks in advance.

Re: Need help with include files

Posted: Sat Nov 08, 2008 10:32 am
by Syntac
Are you echoing the variable before or after the include statement?

Re: Need help with include files

Posted: Sat Nov 08, 2008 11:08 am
by Radiator251
After.

Re: Need help with include files

Posted: Sat Nov 08, 2008 11:16 am
by Ziq
Is there something special I have to do to tell the file where $feed_Economy1 comes from?
No

Try this.

Code: Select all

 
<?php
    $rss1 = "";
    $rss2 = "";
    $rss3 = "";
    $rss4 = "";
   
    // Economy feeds
    $feed_Economy1          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/economy/index_xml";
    $feed_Economy2          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/government/index_xml";   
    $feed_Economy3          = "http://online.wsj.com/xml/rss/3_7014.xml";   
    $feed_Economy4          = "http://online.wsj.com/xml/rss/3_7086.xml";
 
    echo 'This is a test message.';
?>
 
Do you see this message?

Re: Need help with include files

Posted: Sat Nov 08, 2008 2:08 pm
by Radiator251
Yeah, when I access the include directly. When I access the file that is including it, I don't see it. Which theoretically would suggest that I have the URL wrong, but I definitely don't.

Re: Need help with include files

Posted: Sat Nov 08, 2008 2:22 pm
by Ziq
It's strange... try to add this to a top of main php file before include feeds.php

Code: Select all

 
//...
ini_set('display_errors', 1);
error_reporting(E_ALL);
//...
 
Do you get any errors?