tommy20 Posted November 27, 2006 Share Posted November 27, 2006 I am trying to use a php hit counter by calling it through a html file using the following. <? include "counter.php"; ?> But nothing happensThe php file is and is set to 777<?php?><?php$count_my_page = ("hitcounter.txt");?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);$hits[0] ++;?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);$hits[0] ++;$fp = fopen($count_my_page , "w");?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);$hits[0] ++;$fp = fopen($count_my_page , "w");fputs($fp , "$hits[0]");?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);$hits[0] ++;$fp = fopen($count_my_page , "w");fputs($fp , "$hits[0]");fclose($fp);?><?php$count_my_page = ("hitcounter.txt");$hits = file($count_my_page);$hits[0] ++;$fp = fopen($count_my_page , "w");fputs($fp , "$hits[0]");fclose($fp);echo $hits[0];?>What am I doing wrong Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/ Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 For the PHP processor to get invoked by the webserver, your sources needs (in most case) to be named xyz.phpUnless .html files are processed by the PHP processor, what you said you did won't work.Ken Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131162 Share on other sites More sharing options...
tommy20 Posted November 27, 2006 Author Share Posted November 27, 2006 What will work then Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131166 Share on other sites More sharing options...
kenrbnsn Posted November 27, 2006 Share Posted November 27, 2006 You source file needs to be named xyz.phpKen Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131167 Share on other sites More sharing options...
Renlok Posted November 27, 2006 Share Posted November 27, 2006 you cant use any php in a html page someones probly said this already but never mind. Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131187 Share on other sites More sharing options...
doni49 Posted November 28, 2006 Share Posted November 28, 2006 You CAN tell your server to process HTML files through the PHP engine. Other than doing so, you're going to have to either forget this plan or change the extension(s) of your file(s) to php.Are you using CPanel? As that's one of the most common features of web hosting plans out there, I'm going to guess 'yes'.In CPanel, click on [b]Apache Handlers[/b]. Then in [b]Extention(s)[/b] type [b]HTML[/b]. In [b]Handler[/b] field, enter [b]application/x-httpd-php[/b]. Link to comment https://forums.phpfreaks.com/topic/28663-php-in-a-html-file/#findComment-131263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.