Loans | Ringtones | Credit Cards | Credit Cards | Personal Loans
Problems with php goodness [Archive] - ZGeek

PDA

View Full Version : Problems with php goodness


The Avatar
25-10-2004, 09:59 PM
Hoakay,

Ive developed a web counter for my site that tracks each time a user logs onto my main page and when a user goes to the downloads page. Main page is autoloaded each time a user goes to the site, so that becomes the visits stat, while if a person goes to the downloads page the counter will increment the downloads stat.

It works fine on my home web server, but when I uploaded it to my 1337.as hosting service the scripts dont seem to execute. here is the code for incrementing the conter for the main page:


<?PHP
$file = fopen("../Logs/Arachnoid.txt", "r");
$Views = fgets($file,1024);
$Dloads = fgets($file,1024);
$New_Views = $Views + 1;
fclose($file);
$file = fopen("../Logs/Arachnoid.txt", "w");
flock ($file, LOCK_EX);
fputs($file, $New_Views);
fputs($file,"\n"); // Makes sure the next value goes on a new line!!
fputs($file, $Dloads);
flock ($file, LOCK_UN);
fclose($file);

?>


and here is the displaying code:


<?PHP
$file = fopen("../Logs/Arachnoid.txt", "r");
$Views = fgets($file,1024);
$Dloads = fgets($file,1024);
fclose($file);
?>


Why does it not work online, and yet it works perfectly off-line in my web server?

Zan
25-10-2004, 10:10 PM
You should check that the permissions for the file 'Arachnoid.txt' are set so that it can be written to. Changing it to 777 is possibly a little insecure, but I've done that with the .txt file that's currently standing in for my webby.

More information about permissions (http://www.htmlite.com/php042.php)

:edit:

To be honest, I didn't check over your PHP code, so I don't know about its validity. If it's working fine on your home setup, then I'd say it's likely to be a server-side issue, or... something else.

By the way, if you enclose your code within [ PHP ] and [ /PHP ] tags, it will display with syntax highlighting.

The Avatar
25-10-2004, 10:41 PM
You should check that the permissions for the file 'Arachnoid.txt' are set so that it can be written to. Changing it to 777 is possibly a little insecure, but I've done that with the .txt file that's currently standing in for my webby.

More information about permissions (http://www.htmlite.com/php042.php)

Nope, its set for 7,7,7 but still it doesnt display.

Oh heres the link to the actual page: Http://tg.1337.as/Games/Arachnoid.html

Ive check the log file, and its not been incremented either.

Spingo
26-10-2004, 09:12 PM
Is you PHP script embedded in a file that has a .html extension? If so, that's probably you're problem.

In order to make SSI processing as efficient as possible, pur HTML files are not parsed through the PHP pre-processor, as per the Apache configuration directive:

AddType application/x-httpd-php .php .php4 .php3

Try renaming the extension of your file to php, php4 or php3. ;)

The Avatar
27-10-2004, 12:14 AM
Is you PHP script embedded in a file that has a .html extension? If so, that's probably you're problem.

In order to make SSI processing as efficient as possible, pur HTML files are not parsed through the PHP pre-processor, as per the Apache configuration directive:

AddType application/x-httpd-php .php .php4 .php3

Try renaming the extension of your file to php, php4 or php3. ;)

Yeah, thats probably it, because I remember altering my config file on my home web server so that HTML file are parsed through it. I will try this out tomorrow, because I too tired right now. Its 11:45 PM!!!!?

I stop functioning mentaly around 9:30ish at night.

The Avatar
27-10-2004, 01:21 PM
Yup, spingo was right it works perfectly now. Thanks dude!