bonnag Posted March 1, 2009 Share Posted March 1, 2009 Hi, I'm quite a novice with php, but I have had some prior success. I currently stumped over an issue using include. I have also tried require, fopen, file_get_contents too. I have the following code: <html> <body> <?php $page = "http://hopfeed.com/serv/hopFeedServ.htm"; echo $page; include ($page); ?> </body> </html> if I make the page variable equal google.com or another domain it works, but not when I use the above code. The browser page echos the page variable and then just sits there, loading indefinitely. The page that I'm loading isn't straight html, there is stuff going on in the background as you can pass it variables see below: http://www.hopfeed.com/serv/hopFeedServ.htm?type=IFRAME&fillAllSlots=true&align=LEFT&headerText=My%20Ads%20Here&height=400&width=150&linkFontHoverColor=%233300FF&linkFontColor=%233300FF&backgroundColor=%23FFFFFF&font=Verdana%2C%20Arial%2C%20Helvetica%2C%20Sans%20Serif&fontSize=9pt&fontColor=%23000000&rows=3&cols=1&keywords=business&tid=abc123&affiliate=cashexits&cellpadding=5 However, the page that is returned using the above URL has html source. I'm puzzled by this and it is beyond my php skills. Any help would be greatly appreciated. Thanks, bonnag. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/ Share on other sites More sharing options...
bonnag Posted March 1, 2009 Author Share Posted March 1, 2009 I forgot to say. It is not returning any errors. Thanks again, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-773822 Share on other sites More sharing options...
bothwell Posted March 1, 2009 Share Posted March 1, 2009 Well, one thing I can see from the actual url for the page is that it's actually designed to go in an iframe (the IFRAME value that's in the type parameter). I'm guessing that the failure to load is on hopfeed's end as a security precaution and that you're not likely to be able to do what you want to do. You should really be using an iframe for it or seeing if they've got any other specific parameterised URLs that don't rely on an iframe type to work. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-773901 Share on other sites More sharing options...
a-scripts.com Posted March 1, 2009 Share Posted March 1, 2009 Actually it is the setting on your server. You or admin can enable PHP to be able to include or fopen or whatever remote files. For security reasons it might be disabled by default. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-773936 Share on other sites More sharing options...
premiso Posted March 1, 2009 Share Posted March 1, 2009 Actually it is the setting on your server. You or admin can enable PHP to be able to include or fopen or whatever remote files. For security reasons it might be disabled by default. If it is disabled they may allow you to use curl that does the same thing in a sense. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-773943 Share on other sites More sharing options...
bonnag Posted March 1, 2009 Author Share Posted March 1, 2009 bothwell, The link itself opens, even though it contains IFRAME in it. I was under the impression that if I can open it in a browser, that I could use in with a php include. Is this assumption incorrect? Others, Thanks for your suggestions but other URL's work, such as google.com, so as far as I know all the settings are in order. Any other ideas? Thanks, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774005 Share on other sites More sharing options...
thebadbad Posted March 1, 2009 Share Posted March 1, 2009 It could be that the site in question checks the user agent string, and discards requests from "PHP" (the default user agent string when retrieving external pages with PHP). You can set the user agent string PHP uses with ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9) Gecko/2008052906 Firefox/3.0'); at the top of your script. May be a bit immoral, but that's up to you to decide. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774014 Share on other sites More sharing options...
bonnag Posted March 1, 2009 Author Share Posted March 1, 2009 It could be that the site in question checks the user agent string, and discards requests from "PHP" (the default user agent string when retrieving external pages with PHP). You can set the user agent string PHP uses with ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.9) Gecko/2008052906 Firefox/3.0'); at the top of your script. May be a bit immoral, but that's up to you to decide. Thanks for the suggestion, but that doesn't work either! I just can't figure this out.... bonnag. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774124 Share on other sites More sharing options...
corbin Posted March 1, 2009 Share Posted March 1, 2009 First off, include is used when you want to parse the content in the file. You're better off/safer with file_get_contents. Anyway, chances are, there is an error and it's just not showing. At the top of the page, add: ini_set('display_errors', '1'); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774143 Share on other sites More sharing options...
bonnag Posted March 2, 2009 Author Share Posted March 2, 2009 corbin, Thanks for the tip, I added the code. Exactly the same thing happens. No errors are displayed and the page just keep loading and loading, but nothing other than the echo string ever appears. Thanks, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774228 Share on other sites More sharing options...
bonnag Posted March 2, 2009 Author Share Posted March 2, 2009 The thing that confuses me is that the command works for other pages on other domains. Could it be that the page that is being accessed is also php and that there is a confict? Thanks, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774249 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 Well, it definitely has something to do with something on your end. <?php echo file_get_contents('http://hopfeed.com/serv/hopFeedServ.htm'); Works as expected for me. Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774263 Share on other sites More sharing options...
bonnag Posted March 2, 2009 Author Share Posted March 2, 2009 Well, it definitely has something to do with something on your end. <?php echo file_get_contents('http://hopfeed.com/serv/hopFeedServ.htm'); Works as expected for me. Corbin, Thanks for doing that. That is a great help. I'll keep plugging at it. bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774268 Share on other sites More sharing options...
corbin Posted March 2, 2009 Share Posted March 2, 2009 I just don't see how there's no error message.... Doesn't make sense. If you do var_dump() of file_get_contents, is it FALSE? Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774285 Share on other sites More sharing options...
bonnag Posted March 2, 2009 Author Share Posted March 2, 2009 I've changed the code to the following and all that appears in the browser is "1"! <html> <body> <?php echo 1; $page = file_get_contents('http://hopfeed.com/serv/hopFeedServ.htm'); echo 2; var_dump($page); echo 3; ?> </body> </html> Is there script I could run to get a bunch of variables as to what is turn on and off on the server that might shead some light on this? Thanks, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774299 Share on other sites More sharing options...
thebadbad Posted March 2, 2009 Share Posted March 2, 2009 Yes, <?php phpinfo(); ?> "allow_url_fopen" should be On in order for your script to work. If you've got cURL installed, you could try that instead. This is similar to echoing file_get_contents(), just using cURL: <?php $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_URL, 'http://hopfeed.com/serv/hopFeedServ.htm'); $contents = curl_exec($c); curl_close($c); echo $contents; ?> Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-774449 Share on other sites More sharing options...
bonnag Posted March 3, 2009 Author Share Posted March 3, 2009 thebadbad, Thanks. Curl and allow_url_fopen are both on and work with other domains. Could it be that the server that I am trying to access is denying the requests. I am with Hostgator so I wouldn't have thought their IP's were bad. Thanks, bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-775205 Share on other sites More sharing options...
bonnag Posted March 3, 2009 Author Share Posted March 3, 2009 It just started working all on it's own! Thanks for your help. bonnag Quote Link to comment https://forums.phpfreaks.com/topic/147428-solved-include-not-working-on-a-particular-domain/#findComment-775494 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.