homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Parsing PHP with HTML file extension

 10:17 pm on Jan 31, 2013 (gmt 0)

Spent two whole days on one line of code to get a simple PHP comment script working and still no joy.

I don't understand PHP but am good at following step by step instructions word for word!

I have been told that if I add this line of code below to the .htaccess file it will enable me to insert PHP into html... Well the PHP I have inserted shows nothing. So i take it that this is the root cause of the problem...

I have cycled through:

AddType application/x-httpd-php .php .html .htm

AddHandler application/x-httpd-php .php .html .htm

AddType x-mapp-php4 .html .htm

AddType x-mapp-php4 .html .htm

Error log looks like this:

[30-Jan-2013 12:20:44] PHP Notice: Undefined index: identifier_list in /vhost/vhost8/s/t/o/ssdfsdfdsdf.com/www/comments/cache/%%74^748^74858DDB%%admin_identifier_list.tpl.html.php on line 116



 10:38 pm on Jan 31, 2013 (gmt 0)

From what I see: your php interpreter is working just fine. But it does not like your php code itself.

Try to make a file named "whatever.html"
and input this as code in that file:

If your php works, it'll output a whole bunch of settings it is using. Just the fact that it does proves your php works in html files.

Next you'll have to figure out what your php script tries to do and what goes south.

Try to take ist step by step.


 12:02 am on Feb 1, 2013 (gmt 0)

Crystal ball says you're on shared hosting. Before you tear out any more hair, take a look at their own docs, including the wiki if there is one. They may give the formula for permitting php within html. On mine there's no separate mention of php at all; the bit that enables include files (which may happen to be php) is
AddType text/html .html
AddOutputFilter INCLUDES .html

The first line seems like a tautology -- "html should be read as html" -- but you don't hear me arguing.


 11:57 pm on Feb 5, 2013 (gmt 0)

Thank you all.

Still no joy... and losing lots of hair from this! Does the .htaccess have to be in the root folder?


 2:22 am on Feb 6, 2013 (gmt 0)

What is your hosting environment? Such as: Linux / Apache / MySQL / PHP? Shared, VPS, Dedicated? And are you running PHP scripts as an Apache module, CGI, or fastCGI?

I had a major problem few weeks ago due to fastCGI when I moved from one hosting environment to a new one. Took me all day to find a solution which was nothing like previous syntax:

AddHandler php-script .html

It can be added to .htaccess -- may not work for you but worth a try.


 6:16 am on Feb 6, 2013 (gmt 0)

It all depends on how your host has set up their php. One host I work with only needs one line:
AddHandler application/x-httpd-php5 .html .htm
Another host requires this combination:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .html

One host I dropped a long time ago would not work with anything. It wasn't godaddy, but godaddy is one of those kinds of hosts. Lucy24 is right, look and see if your host offers a knowledge base, if not, ask them for their suggestions.
PS it won't work on Windows servers either.


 9:13 am on Feb 6, 2013 (gmt 0)

I think you're looking at the wrong problem.

whatever you had when this log entry was created
[30-Jan-2013 12:20:44] PHP Notice:

shows that the php interpreter was working.

So whatever you had then worked as far as having a configuration that starts php.

What's likely is that the scripts you have aren;t working (properly), but you're not going to fix that in apache configurations of .htaccess files.


 9:19 am on Feb 6, 2013 (gmt 0)


... so now you have to go back and figure out which of your quoted four AddType / AddHandler variants was in effect at the moment the ErrorLog entry was generated ... because whatever you were doing was right :)


 9:34 am on Feb 6, 2013 (gmt 0)

as swa66 said right in the beginning, the problem lies in your code, the error message even tells you where - line 116 (or just before, that could be the line with the next ';')


 1:40 pm on Feb 7, 2013 (gmt 0)

Thank you all! I am now officially bald from this. 1 week on and the frustration is causing me to think about nothing else!

the specifications for the server are below:

PHP Version 5.1.6
Apache 2.0 Handler


Since I am new to the whole concept of PHP - where is line 116? What file? Or....?


 3:53 pm on Feb 7, 2013 (gmt 0)

Apparently this path also looks wrong in the php file:

define('C5T_ROOT', '/etc/httpd/htdocs/comments/');
include C5T_ROOT . 'comment.php';


 3:54 pm on Feb 7, 2013 (gmt 0)

A Hello world dummy script is working OK now so this I guess means html is parsing correctly as php....?

What a nightmare!


 8:11 pm on Feb 7, 2013 (gmt 0)

If a hello world in php is working in a html file: then you're set: php works.

Apparently you're trying to get something pre-made already written in php to work. What exactly ?

Googling for C5T_ROOT and comment.php I find references to something called "Gentlesource comment script". It that what you're trying to use ?

As far as comment fields go: do know that unless you incorporate countermeasures such as a strong CAPTCHA, banning of known bad sources, and a lot of moderation, this is a huge can of worms.


 8:34 pm on Feb 7, 2013 (gmt 0)

Thank you. Yes you are correct - gentlesource comment script is what I am trying to display on the site but nothing will display. Despite the hello world script showing correctly.

The script in question is <?php echo $c5t_output; ?>
It displays nothing. Not even an error message on the page.

The php error log shows this - despite the hello world working?!

[30-Jan-2013 12:20:44] PHP Notice: Undefined index: identifier_list in /vhost/vhost8/s/t/o/stor.com/www/comments/cache/%%74^748^74858DDB%%admin_identifier_list.tpl.html.php on line 116
[30-Jan-2013 12:21:49] PHP Notice: Undefined index: identifier_list in /vhost/vhost8/s/t/o/stor.com/www/comments/cache/%%74^748^74858DDB%%admin_identifier_list.tpl.html.php on line 116
[30-Jan-2013 12:22:04] PHP Notice: Undefined index: comment_list in /vhost/vhost8/s/t/o/stor.com/www/comments/cache/%%6D^6DC^6DC53361%%admin_comment_list_all.tpl.html.php on line 97
[31-Jan-2013 21:02:02] PHP Notice: Undefined index: comment_list in /vhost/vhost8/s/t/o/stor.com/www/comments/cache/%%6D^6DC^6DC53361%%admin_comment_list_all.tpl.html.php on line 97


 9:53 pm on Feb 7, 2013 (gmt 0)

Did you follow the installation instructions ?
Did you configure it all properly ?

Doesn't the maker of the software offer support ?

Go to the admin interface and make sure it's configured correctly.
If it has a way to clear/flush/delete/whatever it is named it's cache: do that.

For the rest: to be honest with help from a generic forum, you're unlikely to get this fixed: you either need help of people who're used to deal with this exact software package and/or somebody with hands-on access.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved