Cannot execute PHP scripts

  1. Everything is properly uploaded under the public_html folder.

  2. /public_html/php is where I have my php scripts, and I have set all file and directory permissions to 777, yet still cannot get any of these scripts to work…Though they all worked fine using the old Cpanel

3)PHP scripts do execute from the URL, for example www.siskiyousoj.us/php/count.php works. It does, however, now though an error, as the script was written for php5, and I turned on error reporting while trying to solve my problem and the new cpanel is set to use php7. Changed to PHP5 failed to solve my problem.

Here’s the count.php code

<?php if (file_exists('count.dat')) { $fil = fopen('count.dat', r); $dat = fread($fil, filesize('count.dat')); // display debug date echo 'the counter is executing'; echo $dat+1; $dat+1; //instead just add one and save fclose($fil); $fil = fopen('count.dat', w); fwrite($fil, $dat+1); } else { $fil = fopen('count.dat', w); fwrite($fil, 1); // display debug data echo 'the counter is executing'; echo $dat+1; fclose($fil); } ?>

here’s a simple html file at (sorry new users can only put one link in a post domain/arg.htm) that I still cannot get to execute my external php scripts!?!?!

Here’s it’s code

<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>blah</title>
</head>
<body>
<p>I'm the content</p>

<!-- simple hitcounter -->  
<?php include "/php/count.php"; ?>

</body>
</html>

So… Why can’t I execute my PHP scripts???

000webhost.com > general settings > change PHP version?

This post was flagged by the community and is temporarily hidden.

Infinity
As I said, changing the php version does not solve my problem

Captainjjjacksparrow
As I said, calling the php script from the URL of the browser does work. but this crazy forum won’ not let me post the second url, the one for the html file calling the php counter, which doesn’t work.

try siskiyousoj dot us slash arg.htm

arg.htm should display
I’m the content

Notice: Use of undefined constant r - assumed ‘r’ in /storage/h5/671/888671/public_html/php/count.php on line 5
the counter is executing
5
Notice: Use of undefined constant w - assumed ‘w’ in /storage/h5/671/888671/public_html/php/count.php on line 12

yet it only displays
I’m the content

as the php script is not executed.

Even after fixing the php so it throws no errors, if I include it in an htm, or html file it will not execute. It’s almost as if it’s a path problem, but even if I put the php file in the root directory(public_html) along with the html doing the calling, with the proper path, the PHP doesn’t execute.

  <?php

if (file_exists('count.dat')) 
{
    $fil = fopen('count.dat', 'r');
    $dat = fread($fil, filesize('count.dat')); 
    echo 'the counter is executing';
    echo $dat+1;                
    $dat+1; //instead just add one and save
    fclose($fil);
    $fil = fopen('count.dat', 'w');
    fwrite($fil, $dat+1);
}

else
{
    $fil = fopen('count.dat', 'w');
    fwrite($fil, 1);
    $dat = 0;
    echo 'the counter is executing>';
    echo $dat+1; 
    fclose($fil);
}

?>

This post was flagged by the community and is temporarily hidden.

@ El_captain_Jack
Looks like it’s path problems, as changing arg.htm to html does not work, but making it arg.php throws the following errors.

I’m the content

Warning: include(/php/count.php): failed to open stream: No such file or directory in /storage/h5/671/888671/public_html/arg.php on line 10

Warning: include(): Failed opening ‘/php/count.php’ for inclusion (include_path=’.:/usr/share/pear:/usr/share/php’) in /storage/h5/671/888671/public_html/arg.php on line 10


I know the path structure changed between 000webhost and hostlinger, as I had to play with paths to reference html files in a subdirectory called news. I’m curious as to why referencing the URL itself from my arg.html/ now php file didn’t work.

Anyway, it seemed like I should have be able to access the scripts in my php directory, while sitting in the public_html directory like so:

<?php include "php/count.php"; ?>

But when that didn’t work, because I couldn’t access another html file in another subdirectory named news without the addition forward slash I added in the arg.htm snipped in far above, I tried adding a forward slash, which still failed then came here.

My current directory structure according to my web based file manager
public_html
----news
----php
tmp

And to be sure, I’m paying attention to case sensitivity. All is lower case. So am I going to have to reference my scripts using that full path above, as in any other linux system, all I gotta do is tell my command line about the directory laying below.

Example execute test.elf not in the search path in the directory called soj below my current directory
soj/test.elf

This post was flagged by the community and is temporarily hidden.

Well, things now work, albeit wrongly. as it turns out, the full path is not required and the problem was all in the file name, as hostinger wont allow htm and html files to call external php scripts, nor can HTM(HTML) run php within themselves. Since when are html files not allowed to call external php scripts, and why? Even before php became php we were writing it directly in our html files alongside the html itself. Thus, In order to execute my external php scripts, I must rename the html files calling them to php, which they most certainly are not, and though this method does work, it hangs most browsers for quite a while before the page finally settles down!!