neagloe Posted January 5, 2010 Share Posted January 5, 2010 Hello,I am using the following PHP code: <?php $header = file_get_contents("http://lionsfutures.com/aafiles/php/header.php"); echo ($header); ?> on the following page: http://lionsfutures.com/live/ This PHP code is valid and from: http://php.net/manual/en/function.file-get-contents.php Please tell me why it is not working now? This code has been on my website for over 9 months and worked perfectly, as of yesterday this code stopped working and is generating errors on my website. Any ideas or suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/ Share on other sites More sharing options...
mikesta707 Posted January 5, 2010 Share Posted January 5, 2010 the exact error messages would help Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988488 Share on other sites More sharing options...
oni-kun Posted January 5, 2010 Share Posted January 5, 2010 Pleas add this code after the first <?php tag: ini_set('display_errors',1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988490 Share on other sites More sharing options...
neagloe Posted January 5, 2010 Author Share Posted January 5, 2010 Thanks! I added the code "ini_set('display_errors',1); error_reporting(E_ALL);" as your suggested. Now when I go to: http://lionsfutures.com/live/ I see: "Warning: file_get_contents(http://lionsfutures.com/aafiles/php/header.php) [function.file-get-contents]: failed to open stream: Connection timed out in /home/content/f/e/2/fe28mzigt21/html/lionsfutures/live/index.php on line 26" "Warning: file_get_contents(http://lionsfutures.com/aafiles/php/rightbar.php) [function.file-get-contents]: failed to open stream: Connection timed out in /home/content/f/e/2/fe28mzigt21/html/lionsfutures/live/index.php on line 41" "Warning: file_get_contents(http://lionsfutures.com/aafiles/php/footer.php) [function.file-get-contents]: failed to open stream: Connection timed out in /home/content/f/e/2/fe28mzigt21/html/lionsfutures/live/index.php on line 66" This is the only PHP code I am using on this page: <?php ini_set('display_errors',1); error_reporting(E_ALL); $header = file_get_contents("http://lionsfutures.com/aafiles/php/header.php"); echo ($header); ?> <?php $rightbar = file_get_contents("http://lionsfutures.com/aafiles/php/rightbar.php"); echo ($rightbar); ?> <?php $footer = file_get_contents("http://lionsfutures.com/aafiles/php/footer.php"); echo ($footer); ?> Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988504 Share on other sites More sharing options...
oni-kun Posted January 5, 2010 Share Posted January 5, 2010 Hmm.. The connection should not time out unless there is a massive amount of data being pulled , or an error with your server. But why are you using file_get_contents? All this does is puts an extra HTTP request through your server to display something that's already on it, you can try: include('../aafiles/php/header.php'); That, (in ideal conditions) is impossible to time out, as it accesses the file from disk not HTTP. Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988505 Share on other sites More sharing options...
neagloe Posted January 5, 2010 Author Share Posted January 5, 2010 Thank you. That is what I am using at www.lionsfutures.com/demo/ and it is working fine. But it is strange because <?php $header = file_get_contents("http://lionsfutures.com/aafiles/php/header.php"); echo ($header); ?> was working perfectly for months, now, suddenly I am getting time out errors. My temporary fix is just to use the require or include code but I like the file_get_contents better because it works (did work) in every file regardless of what directory the file is in. Any idea on why it would randomly stop working on our GoDaddy server? Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988943 Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Share Posted January 5, 2010 include can work no matter the directory as long as you get it in relation to curren directory: in same directory: include('file.php'); next directory up: include('directory/file.php'); last directory: include('../file.php'); back a directory and up 1: include('../otherdirectory/file.php'); Just remember you need "../" for every directory you go back Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988951 Share on other sites More sharing options...
teamatomic Posted January 5, 2010 Share Posted January 5, 2010 Maybe GoDaddy restricted access to opening urls. You should be using a path anyways, so use a path. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988961 Share on other sites More sharing options...
neagloe Posted January 5, 2010 Author Share Posted January 5, 2010 Hello, Thank you all for you help! I hope to be able to help others like you have helped me Happy New Years! Quote Link to comment https://forums.phpfreaks.com/topic/187192-simple-valid-php-not-working-on-my-site-all-the-sudden/#findComment-988990 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.