slaterino Posted September 11, 2008 Share Posted September 11, 2008 I am currently having some problems creating absolute links. I am trying to create a link in my right navigation area for a rss feed. This navigation area features on pages in a number of different levels so I want to create a link like this: require_once ($docroot).'rss/rss.inc' where $docroot is the name of my domain. However when I do this I get this message: Warning: main(http://www.mydomain.com/rss/rss.inc) [function.main]: failed to open stream: Connection refused in /home/sites/mydomainname.com/public_html/news/index.php on line 18 Fatal error: main() [function.require]: Failed opening required 'http://www.mydomain.com/rss/rss.inc' (include_path='.:/usr/share/pear') in /home/sites/mydomain.com/public_html/news/index.php on line 18 When I use relative links such as require_once '../rss/rss.inc' I don't get this problem at all. Does anyone know what could be causing this? Thanks Russ Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/ Share on other sites More sharing options...
GingerRobot Posted September 11, 2008 Share Posted September 11, 2008 And what is the value of $docroot? Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-638969 Share on other sites More sharing options...
slaterino Posted September 11, 2008 Author Share Posted September 11, 2008 $docroot=('http://www.mydomain.com/'); Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-638995 Share on other sites More sharing options...
Jabop Posted September 11, 2008 Share Posted September 11, 2008 $docroot=$_SERVER['DOCUMENT_ROOT']; Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-639017 Share on other sites More sharing options...
Maq Posted September 11, 2008 Share Posted September 11, 2008 Shouldn't it be w/ french braces? require_once {$docroot}.'rss/rss.inc' Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-639036 Share on other sites More sharing options...
GingerRobot Posted September 11, 2008 Share Posted September 11, 2008 Or no braces at all. Didn't even notice the brackets on first glance. Should either be: require_once $docroot.'rss/rss.inc'; Or: require_once ($docroot.'rss/rss.inc'); Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-639055 Share on other sites More sharing options...
slaterino Posted September 16, 2008 Author Share Posted September 16, 2008 Hi, I've tried all the suggestions for trying to get this working and am still getting the error message of: Warning: main(http://www.mydomain.com/rss/rss.inc) [function.main]: failed to open stream: Connection refused in /home/sites/mydomain.com/public_html/news/index.php on line 60 Fatal error: main() [function.require]: Failed opening required 'http://www.mydomain.com/rss/rss.inc' (include_path='.:/usr/share/pear') in /home/sites/mydomain.com/public_html/news/index.php on line 60 I've tried using $docroot=$_SERVER['DOCUMENT_ROOT']; as well as $_SERVER['PHP_SELF'] and $_SERVER['HTTP_HOST'] and keep getting the same response. Is there some kind of restriction that could be stopping the script from being accessed properly. Any help would be greatly appreciated! Thanks Russ Quote Link to comment https://forums.phpfreaks.com/topic/123748-problem-with-absolute-link/#findComment-643335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.