ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
and I wish to include the following php script into it
Code:
<?php
$filename = "/media/pi/MyPassport/Axpert/solar.log"; // file to read
$max_len = 110 + 1; // define the max length of the line to read
$buff; // [$max_len + 1]; // define the buffer and allocate the length
if (($fd = fopen($filename, "rb")) != NULL)
{
fseek($fd, -$max_len, SEEK_END); // set pointer to the end of file minus the length you need.
// Presumably there can be more than one new line caracter
$buff = fread($fd, $max_len-1); // read the contents of the file starting from where fseek() positioned us
fclose($fd); // close the file
}
else
printf("%s %d FileOpen error\n",__FILE__, __LINE__);
$last_newline = strstr($buff, 'IGS ');
sscanf($last_newline, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s", $command, $voltage_grid, $freq_grid, $voltage_out, $freq_out, $load_va, $load_watt, $load_percent, $voltage_bus, $voltage_batt, $batt_charge_current, $batt_capacity, $temp_heatsink, $pv1, $pv2, $scc, $batt_discharge_current);
printf("\tAC Grid voltage: %s\n", $voltage_grid);
printf("\tAC Grid frequency: %s\n", $freq_grid);
printf("\tAC out voltage: %s\n", $voltage_out);
printf("\tAC out frequency: %s\n", $freq_out);
printf("\tLoad [percent]: %s%%\n", $load_percent);
printf("\tLoad [W]: %s\n", $load_watt);
printf("\tLoad [VA]: %s\n", $load_va);
printf("\tBus voltage: %s\n", $voltage_bus);
printf("\tHeatsink temperature: %s\n", $temp_heatsink);
printf("\tBattery capacity [percent]: %s%%\n", $batt_capacity);
printf("\tBattery voltage: %s\n", $voltage_batt);
printf("\tBattery charge current [A]: %s\n", $batt_charge_current);
printf("\tBattery discharge current [A]: %s\n", $batt_discharge_current);
printf("\tPV Input Current [A]: %s\n", $pv1);
printf("\tPV Input Voltage [V]: %.s\n", $pv2);
?>
The php works fine from the command line and if I disable the include in the HTML it also works.
A look at apache2 configuration appears to be allowing me to use php, so please tell me what I forgot?
Look at the /var/log/apache2/error.log for errors that should help you troubleshoot the problem. The web server typically runs as the apache2 user and may not have permissions to access the log file.
It is not clear to me what you mean when you say that it works if you disable the include. And you have not told us what you see when it "does not work" - any error messages, visible code or a blank page?
As others have asked, do other php scripts work on this server - that is, is php enabled in the apache configs? Does this line produce any visible output?
Code:
<?php echo getcwd(); ?>
Please try to be more complete in your description and provide any error messages that appear in the page, or in the apache logs. Help us help you!
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Original Poster
Rep:
I have looked in the apache2 logs and access.log shows that the html is connecting and that is all. The error log shows nothing.
The LastLine.php is in the same directory and I get no output from getcwd.
I have tried both required as well as include and still I get a blank screen.
Not only do other php scripts work including phpinfo but LasLine.php also works if called from command line.
There is no error message just a blank screen.
When I disable the include the html loads.
astrogeek if I had any more information I would certainly share it.
If it helps at all you can try browsing to 196.32.102.29/lcars/solar5.html and if you do look at the page source and tell my why the two php lines are red, implying an error, but what.
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Original Poster
Rep:
If I rename solar5.html to solar5.php at least it starts to work. Now to see why my proggie cannot open that file. Probably permission error.
Thank you for your patience and help
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.