Forum Moderators: coopster

Message Too Old, No Replies

Using PHP includes in a .shtml page

is it possible?

         

nevdev

5:10 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



I have a PHP page on an ecommerce website with some PHP includes in it. I use these PHP includes in a sort of stock/price CMS system - they call other PHP files which look up the correct price of an item in a textfile database, and slap the correct price wherever it's needed on the page.

It all works fine, but then on the same page I tried using a javascript which does some fancy work to display the current shopping cart contents. It didn't work because the remote shopping cart page's "continue shopping" button couldn't be fixed to GET, only to POST (if it detects that the return URL is to a script - ie a PHP page - it overrides the settings and makes the POST method stick).

So I thought to get around this I'd turn the page into a .shtml page instead, so the cart wouldn't detect a scripted PHP page. But of course now the PHP includes don't work in the .shtml page (I get the "[an error occurred while processing this directive]" message).

Is there any way I can get the PHP includes to work on a .shtml page? Or is there another way to call these "look-up" PHP files on a .shtml page?

Blackie

12:21 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



I wonder if it helps adding an apache directive to parse .shtml files for php code.

nevdev

1:25 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



Thanks, but could you be more specific? How do I do this? What commands would I have to issue?

Blackie

2:08 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



You can add the following line to the .htaccess file in your root directory:

AddType application/x-httpd-php .shtml

--------------
But I dont know if this solves your problem. Just my guess :-)

jatar_k

4:21 pm on Jun 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that won't work, double parsing a page always causes problems

why not just use SSI

include virtual or exec to include the php pages?

nevdev

5:34 pm on Jun 30, 2005 (gmt 0)

10+ Year Member



Hmm.. I checked this out, and you're right, changing the .htaccess file like that appears to make lots of problems.

I can't use SSI include virtuals because I use the PHP includes inside links, and you can't do that with virtual includes.

Anyhow I found a PHP way of doing the work that the javascript does.

Interesting conundrum of mixed scripting languages though!

Thanks for the comments and advice.