Jump to content

Simple & Valid PHP Not Working on My Site... all the sudden


neagloe

Recommended Posts

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?

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.