Orionsbelter Posted October 17, 2014 Share Posted October 17, 2014 $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); Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/ Share on other sites More sharing options...
ginerjm Posted October 17, 2014 Share Posted October 17, 2014 Do you have a question? Other than the probable errors you have because you wrapped your vars in quotes? Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1493992 Share on other sites More sharing options...
Orionsbelter Posted October 17, 2014 Author Share Posted October 17, 2014 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); Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1493999 Share on other sites More sharing options...
Orionsbelter Posted October 17, 2014 Author Share Posted October 17, 2014 The above code, seems to not work as the file is in another directory why is this? Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1494000 Share on other sites More sharing options...
Ch0cu3r Posted October 17, 2014 Share Posted October 17, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1494014 Share on other sites More sharing options...
ginerjm Posted October 17, 2014 Share Posted October 17, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1494025 Share on other sites More sharing options...
jcbones Posted October 18, 2014 Share Posted October 18, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/291882-reading-text-from-a-php-file/#findComment-1494091 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.