Welcome to WebmasterWorld Guest from 54.145.222.231

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Parsing PHP with HTML file extension

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

5+ Year Member



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)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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:
<?php
phpinfo();
?>

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)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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)

5+ Year Member



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)

WebmasterWorld Senior Member



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)

WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month



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)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



D'oh!

... 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)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

5+ Year Member



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

[vhost8.yoursitepreview.net...]

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)

5+ Year Member



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)

5+ Year Member



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)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

5+ Year Member



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)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.