akacj wrote:
I have a text file that error information gets logged to from a visual basic application.
You need to provide this file path, and to provide PHP access to this file either on the same machine, or by uploading the file to a server where PHP can access it.
Gaining access is as much about knowing the path, as setting the correct permissions to read the file (all you have asked PHP to do so far is read the file and output it's contents with some surrounding HTML, PHP is awesome for this)
akacj wrote:
In a php page, I want to be able to see that data in a container or text area.
So assuming you kept this really really simple, and uploaded the file with read permissions for whatever user PHP is running as, (i.e. on linux chmod 444 to '/var/www/logfile.txt'), and you save your PHP file as '/var/www/log.php', PHP is setup and working and your web-serve folder is '/var/www'
Try this.
<?php
$logtxt = @file_get_contents('/var/www/logfile.txt');
if( strlen($logtxt) < 1 ) {
$logtxt = 'The log file is unavailable or empty';
}
echo sprintf('<textarea>%s</textarea>', $logtxt);
akacj wrote:
I also want it to be live updating.
Now "live", even on the TV assumes some time between something happening and you seeing / hearing about it, so to keep it simple let's say you do not want to connect a windows machine to the internet to serve a PHP file, and you will upload the file maybe once per day using an automated script or some program.
consider this revision to the above
<?php
$logtxt = @file_get_contents('/var/www/logfile.txt');
if( strlen($logtxt) < 1 ) {
$logtxt = 'The log file is unavailable or empty';
}
header('Refresh:'.(60*60*24).';url=/log.php'); // 60 seconds * 60 minutes * 24 hours = roughly 1 day after page loads, refresh
// I would not set this to be less than 60, there are other ways to refresh
echo sprintf('<textarea>%s</textarea>', $logtxt);
Does this help more than the previous replies?