Jump to content
Orionsbelter

Reading text from a php file

Recommended Posts

 

$tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
$tracking_file                 =  fopen("$tracking_file_location", "r") or die("Unable to open file!");
$tracking_file_size        =  filesize("$tracking_file_location");
$tracking_file_text        =  fread($tracking_file,$tracking_file_size);
fclose($tracking_file);

Share this post


Link to post
Share on other sites

Do you have a question?  Other than the probable errors you have because you wrapped your vars in quotes?

Share this post


Link to post
Share on other sites

Apologise, for some reason my text hasn't posted. 

 

 

$tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
$tracking_file                 =  fopen($tracking_file_location, "r") or die("Unable to open file!");
$tracking_file_size        =  filesize($tracking_file_location);
$tracking_file_text        =  fread($tracking_file,$tracking_file_size);
fclose($tracking_file);
 

Share this post


Link to post
Share on other sites

How would we know why the file is in another directory? We are not sat beside you. 

 

It would be helpful if could actually explain what it is you are trying to do. Just posting a few lines of code is not going to yield you any helpful replies. Also if you are getting any error messages post them in full.

Share this post


Link to post
Share on other sites

Yes - tell us what "is not working".  How smart do you think we are?  Smart enough to see something where there is nothing?

 

PS - add the code in my signature to turn on error checking at least.  Then run it and tell us what you get.

Share this post


Link to post
Share on other sites

Specify the exact path to the file:

 

$tracking_file_location    =  "/home/www/exact/path/to/dispatch-manager/logs/tracking_file.txt";

 

Relative file paths will always cause problems. Especially, if the current file is included in a file that is located in a different location.

Share this post


Link to post
Share on other sites

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.