Warning: include_once(/www/templates/gt/parts/blogs/carptips/first.php) [function.include-once]: failed to open stream: No such file or directory in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 19

Warning: include_once() [function.include]: Failed opening '/www/templates/gt/parts/blogs/carptips/first.php' for inclusion (include_path='.:/usr/local/lib/php') in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 19

Friday, June 10, 2005

Displaying feeds in non-PHP pages 

CaRP is most commonly used to integrate RSS feeds into PHP pages--that is, webpages whose name ends with ".php". Why does the filename extension matter, and how can newsfeeds be displayed on pages with different filename extensions?

The reason that the filename extension matter is that the webserver software uses the extension to decide whether and how to process the file before sending it to the web browser. If the extension is ".php", that tells the webserver that it may contain PHP code, and that that code should be executed before sending the data to the browser. If it ends with ".asp", that tells the webserver that the file may contain ASP code that needs to be executed. Similarly, an ".shtml" may contain SSI code that needs to be executed.

By only attempting to execute the kind of code that's indicated by the filename extension, the webserver can run faster, and security is increased because the likelihood of accidentally executing something that wasn't meant to be interpreted as executable code is minimized. Generally, files with the extensions ".html" and ".htm" do not contain any code for the server to execute (though they may contain JavaScript code to be executed by the web browser). Thus, ".html" and ".htm" can be server more efficiently than other kinds of files.

Once the server has finished any necessary code processing, the filename extension no longer matters, because in the end, the data that is sent to the web browser is always HTML (...at least in all the cases I'm discussing now. Obviously there are other cases like images, stylesheets, files containing only JavaScript code, etc.)

So let's say you want to display a feed in a file named "thenews.html". You could use JavaScript, but that wouldn't work for people who have JavaScript disabled in their browsers, and wouldn't help with search engine optimization, since search engines don't look at JavaScript. If "thenews.html" is a new file, you could just name it "thenews.php" instead. But if it's an existing file that's linked to from various other places, possibly including the search engines, what you'll want is a way to run PHP code in a ".html" file. If you're lucky, your web server is running Apache, and the server administrator hasn't disallowed the following. If either of those isn't the case, there may not be a solution available to you.

The way to get Apache to execute PHP code in ".html" files is to put something like the following into a file named ".htaccess", and to upload it to your webserver (or if you already have a .htaccess file, just add this line to it--don't just overwrite the old file, or other things may stop working!):

AddType application/x-httpd-php .html

Update: on some servers, that should be as follows instead:

AddHandler cgi-script cgi PHP html

The same applies to the code below too.

The .htacess file needs to go into your web directory either in the same folder where the ".html" file in question is located, or in a directory closer to the root. For example, if http://www.example.org/news/stories.html is located at /home/username/www/news/stories.html, then the .htaccess file could go in either /home/username/www/news or /home/username/www.

Note that the above line would tell Apache to processing PHP code in all .html files. If you're only going to add PHP code to one .html file, it's better to do this:

<Files stories.html>
AddType application/x-httpd-php .html

That way, only files named "stories.html" will have the extra processing applied to them.

Be aware that when PHP processing is turned on for a file, any part of the file that begines with "<?php", and in many cases ">?" is going to get treated as PHP code. If your file is in XHTML format and you have an XML prologue in it (eg. "<?xml version="1.0" encoding="ISO-8859-1"?>"), you may see a syntax error rather than a webpage. The solution to that problem is to use PHP to output the XML prologue, or at least part of it, like this:

<?php echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; ?>

or this:

<?php echo '<'; ?>?xml version="1.0" encoding="ISO-8859-1"?>

One note in parting. If you want to display a feed in a ".shtml" page, you can do this easily by putting all of the PHP code into a separate file with a ".php" extension, for example, "stories.php", and then using SSI to incorporate it into the ".shtml" file like this:

<!--#include virtual="stories.php"-->

3/18/2006 Update

The SSI example above may need to be modified a little to work on your server. Here are two more things to try if the above doesn't work:

<!--#include virtual="/path/to/stories.php"-->

...where "/path/to/" is the path from your web root to the file--just "/" if it's in the web root directory itself.

<!--#exec cgi="/path/to/stories.php"-->
// posted by Antone Roundy @ 3:21 AM


By Anonymous Anonymous, at January 03, 2006 2:41 PM  

Thank God!!! I've been searching for this exact type explanation of how to run php through HTML pages for 2 solid weeks, now. THANKS EVER SO MUCH for posting this!!!!!

By Blogger strive4impact, at January 16, 2006 12:00 AM  

Thank-you for this tutorial! One question...

So you showed how to get it to process for a single file, and you showed how to get it to process site-wide... is there a way to get it to process for just a directory? e.g. I have a directory called mysite.com/blog. How would I get it to just process in /blog and all subs of /blog?

By Blogger Antone Roundy, at January 16, 2006 8:02 AM  

Ah, good question. To process one directory and it's subdirectories, make a .htaccess file in that directory and use the site-wide style setting.

By Anonymous Anonymous, at January 17, 2006 11:41 PM  

My host uses linux servers & does not support .htaccess files. Is there anything you can think of that I might try, to use php within my html file?

By Anonymous Anonymous, at February 18, 2006 2:42 AM  

how do I creat a .htaccess .
With which program can I create this file there is none in my webserver

By Blogger Antone Roundy, at February 18, 2006 8:23 AM  

You can create a .htaccess file using any text editor that can save files as plain text.

By Blogger Bob Tyndall, at March 10, 2006 10:17 AM  


I am in the process of setting up a feed. Whjat I haven't found is how to formate what the feed will look like on my page. I need it to go into a specific area to match my page. Is this possible?


By Blogger Antone Roundy, at March 10, 2006 11:24 AM  

Information about display formatting is here. I'm afraid I'm not sure what you mean by "I need it to go into a specific area". Just put the code the calls CaRP in the spot where you want the feed to appear. Does that answer the question?

By Blogger NewzMom, at March 10, 2006 12:39 PM  

You are a GENIUS!

By Blogger NewzMom, at March 10, 2006 12:42 PM  

My WebMistress the "NewzMom" is going to get a chuckle out of this! -- Jim

By Blogger i8bozo, at March 11, 2006 3:26 AM  


Brilliant work! I thank you and congratulate you all at the same time. I happily paid the 29/30 dollars for the evolution version of carp. Easily worth it.

It will do well in helping me flesh out www.movie-career.com and it's so easy!!

Good things are coming.

Rock on!


By Anonymous Anonymous, at March 17, 2006 10:24 AM  

How come alot of rss feeds are in a format that looks similar to html which start with a RSS tag

instead of an url that i have in my code that was produced by the configuration php

how do we input that carp?

By Blogger WeListHomes4Less, at March 19, 2006 8:28 PM  

Great work. Everythihg is working really well, but now I want to use the apache capability to add Include files. Naming my files with .html doesn't work to include an include file into a page, but when I use the .shtml extension, I get the include, but loose the CaRP feed and get this error code where the feed should be:

# '); CarpConf('aitems',''); // put "list item" tags before and after each item CarpConf('bi',''); CarpConf('ai','
'); CarpCacheShow('http://rss.indeed.com/rss?q=marketing+title%3Adirector&l=Los+Angeles&limit=50&jt=fulltime'); ?>



By Blogger Antone Roundy, at March 20, 2006 8:20 AM  

What's happening is that the PHP code in the include file is not getting executed--the code is just getting displayed. Two things to do:

1) Make sure the filename extension for the include file is ".php".

2) Try writing the include tag in a few different ways as mentioned at the bottom of this article (use #include, #exec, file=, virtual=, cgi=...). Some servers work with one combination of those but not with others.

By Anonymous Anonymous, at March 23, 2006 4:16 AM  

Sorry, but it seems I am really nuts.
Installed everyting and my page shows just the code I copied from the istallation page, not even an error message.

require_once '/home/virtual/site95/fst/var/www/html/carp/carp.php';
// Add any desired configuration settings below this line using "CarpConf" and other functions

By Blogger stleonardscarboot, at March 25, 2006 7:20 AM  

hey, so i'm trying to get this .htaccess thingy going...i'm using frontpage so could this be causing me problems? 2 things...
a) do i literally type:
AddType application/x-httpd-php .html

or do i modify or replace "add type"


b) my server seems to like deleting any .php files i try and save on it...erm why?!

By Anonymous Anonymous, at March 25, 2006 3:39 PM  

How do i get the description text to the colour i want?! and able to be picked up by the search engine spiders?

By Blogger Antone Roundy, at March 27, 2006 12:20 PM  

Answers to recent questions:

1) Nothing shows up--not even errors: does the name of the page you pasted the code form the installer into end with ".php"? If not, what steps have you taken to try to get your webserver to process the PHP code?

2) .htaccess: Probably add that line to your .htaccess file, but it depends on what you already have in it. What AddType lines do you already have?

3) Deleting PHP files: I have no idea. That's pretty bizarre. I'd recommend contacting your hosting provider about that.

4) Description text color: try this (using whatever color you want):

CarpConf('bidesc','<div style="color:#003366;">');

5) Search engine spiders: If you can see the feed content when you "view source" in your web browser, the search engines can see it. with CaRP, that will be the case as long as you're not using the JavaScript output feature.

By Blogger stleonardscarboot, at March 28, 2006 5:05 PM  

quite simply antone, your a legend. one more thing though, testing out my rss feeds now they're up and running, but i cant stop the border from spilling into the rest of page in some places (take a look at the bottom of my test page at: http://www.stleonardscarboot.co.uk/testing/indextest.php)

any idea how to stop this?

By Blogger stleonardscarboot, at March 28, 2006 5:28 PM  

oh, and for some reason the whole lot seems to want to stick to the left hand side of the page despite everything I can think of to align it on the right!

sorry to be a pain...

By Blogger seanyglass, at April 11, 2006 8:19 PM  

ive done everything right as far as setting up carp but i dont know how to get rss feeds from other pages to my site...its an html file and i ran the (AddType application/x-httpd-php .html)in my htaccess but i dont know wut to do after that ...can someone please help?

By Anonymous Rolf Arne Trondhjem, at May 31, 2006 5:19 PM  

I managed to install carp in about 10 minutes, great script!
But, I have a problem:
I am using AdSense codes on my index page, but it shows wrong keywords.

If I add index.php like this:
everything looks ok.

What is the problem?

I have seen this in other pages too.

By Anonymous Anonymous, at May 31, 2006 7:20 PM  

Hi ...
i have also installed carps on my server to feed some news to my article directory ...Installation was a breeze...no error messages. But it does not display any news on my site. I have used the following code:

require_once '/home/mysite/public_html/mysub/carp_free/carp/carp.php';
// Add any desired configuration settings before CarpCacheShow
// using "CarpConf" and other functions


have replace <> to # for displaying it here

Did I do anything wrong...??
any help is appreciated ...

By Anonymous Anonymous, at June 13, 2006 10:59 AM  


You are the man with the answers! Everything works great. I'm setting my site up with .htaccess so I can keep my indexed pages the same name with .html extensions. But when I add the Addtype line to the .htaccess file, it gets rid of my left navigation (put there using SSI). I have another line in the .htaccess that uses Addtype. Is this the problem? Thank you.

By Blogger Isabelle, at June 13, 2006 9:24 PM  


I think it is a great software and installs real easy. I also used the .htaccess file. However, it seems only working for my index file. All my other files in the same directory comes up as blank. I checked the source code and they are blank. But, I view the file in ftp folder and they all look normal and identical to the index page in term of formatting. Can you help me out? Thanks.


By Anonymous Rob192, at June 30, 2006 5:37 AM  

My htaccess file was completely empty.
I added the one line
AddType application/x-httpd-php .html
and it crashed my site.

I changed the line to
AddType x-httpd-php .html
and at least my web pages display.

Now for the next problem -
my server is not recognising the php statements. ???

By Anonymous rob192, at July 03, 2006 5:49 AM  

The answer for me was
not AddType, or ForceType.

and the
was necessary.

By Blogger AJD, at July 11, 2006 6:14 PM  

My host says that their .htaccess only supports AuthType.

Is that the same as AddType?

By Anonymous Steve O, at July 16, 2006 4:55 PM  

I too am having difficulty with .htaccess. I didn't have a .htaccess file on my (Apache/PHP4) site, so I figured I was safe writing one with a single line in it. Added AddType application/x-httpd-php .html and saved to root as ASCII.

When I tried to open my site in Firefox it wanted to download every page and open locally, same with IE.

Tried replacing AddType with AddHandler and everything is normal except no output from CaRP. Wrote a .php page and CaRP works fine there, but I want to add to existing .html and preserve the links. Any ideas what might be going on?

I am currently using FrontPage 2000, would that have any impact?

By Blogger Douglas Case, at July 20, 2006 1:40 PM  

Antone, This looks like a great application. I'm testing it out but I ran into a seemingly simple issue I can't resolve:

It works great on .php files, I followed your instructions for use in a .htm file and it's not recongizing the php script. I have a one line .htaccess in the same root directory with the line "AddType application/x-httpd-php .html"

I'm using a shared 1and1 hosting account.

Can you point me in the right direction? This is a stupid question but I just throw the php code in my .htm file, right? There's nothing "special" I have to do to the code when it's in my htm file?

Thanks in advance,

By Anonymous Ainuddin Mohamad, at July 26, 2006 8:39 AM  

I'm the Webmaster of BestWebsites.com.my. I had bought tons of books about RSS stuffs. The more I read the more confusions.
Thanks to a set of videos by Louis Allport entitled "How To Add Automatically Updating Content To Your Website" I was able to learn about CaRP. To those having blur eye sight, almost looks like "crap" but believe me CaRP is a ton of precious diamonds.

By Anonymous Anonymous, at August 08, 2006 8:02 AM  

I read Apache's documentation here http://httpd.apache.org/docs/1.3/howto/ssi.html. As far as I understand, the principle is how to tell the Apache server to also "execute" your .html files, not only "read" it as usual.
In that document, the instruction is for .shtml files, which is in your .htaccess should be:

AddHandler server-parsed .shtml

I think, in case of .html it should be:

AddHandler server-parsed .html

This will tell Apache server to parse ALL .html files, even if they don't contain any #include directive. This gives additional load to your server and can slow things down quite a bit; so, is not a good idea.
If only a few .html files contain #include directive, best is using this method:

1) in your .htaccess write this line:

XBitHack on

This will tell Apache to parse only those .html files that contain #include directive.

2) Make those .html files "executable", by changing their mode (atributes):

chmod +x pagename.html

Hope this helps.

By Anonymous rob192, at August 17, 2006 5:34 AM  

Hi Steve O, from July 16

I remember I had the same outcome - blank space where the feed should have displayed.

I think what solved that one for me was setting the permissions of the web page on the server to 755.

(You probably tried that tho')

By Anonymous Terri, at September 06, 2006 5:18 PM  

I'm having a hard time getting a feed to display on a shtml page. I can get it to display on a php page just fine. I've tried all kinds of SSI variables, but I think it may be something in my htaccess file. Can someone take a look and let me know if there is something else I can try? Thanks. Here's what's in my .htaccess file:

AddType text/html .shtml
AddHandler server-parsed .shtml
XBitHack on
Files test.shtml

Note: the last two lines have the carets around them.

By Anonymous stephond, at September 09, 2006 12:12 PM  

Parse error: parse error, unexpected $ in /homepages/0/d175375565/htdocs/weather/index.php on line 90

any help?please

By Blogger Matt, at September 15, 2006 7:08 AM  

I am using Doster as a host and a linux account. I had to add

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

to my .htaccess file for this to work.


By Anonymous prabir, at September 16, 2006 1:28 AM  

I have installed CARP and it is working fine but I am facing problem with .htaccess fiel as I want to run the php script in html file. I have created .htaccess file with the given code and uploaded it to wwwroot. It display the html part but doesn't show the rss feed. Do I need to change somehting...plz advise

By Blogger Victor, at September 27, 2006 7:34 AM  

Frontpage users for .html , put "XBitHack on" in your .htaccess , changemod of page to 777. Then use <!--#include virtual="rssfeed.php" -->
where you want feed to appear.

.htaccess should look like this:

# -FrontPage-

Options +FollowSymlinks

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
order deny,allow
deny from all

AuthName www.pattayacitythailand.com
AuthUserFile /home/patt/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/patt/public_html/_vti_pvt/service.grp

XBitHack on

I hope that helps. working page http://pattayacitythailand.com/welcome.html

By Blogger Victor, at September 27, 2006 6:12 PM  

change mod to 755 and not 777 like I said before.

By Blogger David Viney, at November 18, 2006 10:07 AM  

Re: 1and1 hosting on Linux.

Found the key FAQ at: http://faq.1and1.com/scripting_languages_supported/php/7.html

All you do is place:
AddType x-mapp-php4 .html .htm
In your .htaccess fileā€¦

Then run the setup program:

And copy and paste the code that appears at the bottom into the web page you want to display the feed in.


By Blogger soccercoach, at November 30, 2006 11:03 PM  

OK so I have not yet seen anyting specific to Word Press. I am trying to use Carp to put feed on WP pages. No luck. Changed the htaccess. no luck.

Hmm what to do. Tried putting the feed in my sidebar.php to see if it would fly. Nope crashed my sidebar...



By Anonymous Mike, at December 04, 2006 1:19 PM  

I was having a problem getting my .php file to parse also. I tried adding the recommended commands to the .htaccess file which didn't work. The solution for me was to go to my website administration panel and go to the "handlers" and add a special handler for .htm .html and select server-parsed. Hope this helps someone.

By Anonymous No Adware, at December 07, 2006 4:52 AM  


Do you offer installation service please?
I understand it won'y be free?

I cannot get it to work...

Thanks a lot!

By Blogger Don, the Window Cleaner, at December 30, 2006 4:49 AM  

I am now officially beating my head on the wall.

To begin with, I am a PHP virgin. I have previously depended on a 3rd party service for this function called rssfeedreader.com. They have a site where I enter the name of the feed and check off various parameters, and they create the php script on the fly. I copy the bugger onto my site with Frontpage, save the page as .shtml, with SSI turned on, insert the tag onto the page (which this blog won't let me display here...) and BADDA-BING! The sucker works.

But, it runs though their server, places an ad on it, and I'd just like more control.

What I want to know is, where do I list my feeds? Do I open carp.php, hunt down one of the functions and insert them there? Do I create new php files for each feed, like I did with the other service?

Have mercy on me, a newby... (smites chest)

By Anonymous Anonymous, at January 04, 2007 11:25 AM  

Hi Antone,

I had No Problem with this set-up, (thank the lord). My only question is, when I changed my .html pages to .php the only way they display is by having both php and html extensions in the url? Example; www.mysite.com/another-page.php.html Is this normal???

By Anonymous Frank Calderon, at January 08, 2007 4:31 PM  

THANK YOU, THANK YOU, THANK YOU, thank you a thousand times!!!!!!!

I have tried 50 ways to Sunday to fix a specific problem on my website that precluded me from selling ads via Text Link Ads.com but thanks to your simple fix, I have solved this extremely frustrating problem!

I have little programming knowledge so everything I could find was a puzzle to me until I found your site.

Thanks a million!!!!!

By Anonymous Anonymous, at February 08, 2007 4:32 AM  

#1 Instructions for adding PHP code to an HTML site;
PHP scripts do not automatically work on html pages. If you have an HTML or (.HTM) based site, in order for PHP scripts to run on your .htm or .html pages you have a 2 options or you can add them both;

For Apache Servers Edit your .htacess with:

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

Then Add the php code from the reader directly to your html pages

also try

Addhandler application/x-httpd-php .html .php

By Blogger Joseph, at February 23, 2007 4:41 AM  

Hi antone,
I realized that my servers dont use Apache. do you have or know where I could get an IAS workaround?


By Blogger John Aebi-Magee, at May 21, 2007 12:28 PM  

I solved my display problems by changing permissions on the CARP folder to 755 including all sub folders and files. Before I was only getting 3 errors instead of the news feed.

By Anonymous Anonymous, at July 03, 2007 10:59 PM  

After I switched servers I could no longer use the "AddType" option, and AddHandler didn't work either. What did work was moving all the CaRP PHP code to a new file "stories.html" and then just using the one simple #include line 'virtual="stories.php"' on the html page I wanted the feed. (I also had to reinstall carp because in the upgrade to the new server there was a glitch in the cache folders/files that cleared on reinstallation.) In a way, I like this alternate arrangement better than the old AddType way.

By Blogger Max, at July 13, 2007 6:52 PM  

I too am having .htaccess problems.
my .htaccess file:

Files Contact_page.html>
AddType application/x-httpd-php .html

Uploaded in acsii mode, but still get 500 Internal Server Error

Any ideas?


By Blogger Pete Nisbet, at July 27, 2007 6:43 PM  

I too get an internal server error.

I purchased carp koi and Grouper a couple of months ago and still haven't managed to get Carp working. I need some help here.

I've tried everything but no success. I've tried not to ask for my money back because I and a solution, not a refund.

p.s. do these comments get replies? I haven't seen any for ages.

Is the fcat that I use subdomains of any relevance?

By Anonymous Anonymous, at August 17, 2007 2:52 PM  

Can this be implemented in .html pages under Windows IIS?

By Anonymous cashcowworld, at October 16, 2007 10:19 AM  

Finally! Thanks for all of you posting. What finally worked on my htm page was:

Addhandler application/x-httpd-php .htm .php

By Anonymous kat, at October 29, 2007 3:14 PM  

Hi all!
I have tried everything. My site is hosted by Aplus on an Apache server and I'm trying to add a php rss feed to an html page. I even made the same page on shtml. I have tried all the combinations of Addtype, Addhandler etc. Nothing worked! I can finally see a line of giberrish with weird characters on the shtml page but that is a far cry from an rss feed.
Any ideas?

By Anonymous Not so happy camper, at February 02, 2008 9:44 AM  

Let's see. I bought Crap and it was easy to install, had trouble getting it to work, read every post on here. The problem I'm having is that every time I load my website now I get a download prompt? Not what I was wanting to accomplish. I notice that no one has posted here for three months and the master himself "Antone" hasn't been around for almost 2 years. Can you say refund?

By Anonymous Anonymous, at March 19, 2008 8:11 AM  

You should be asking your support questions in the forums: http://forums.geckotribe.com/

By Anonymous Anonymous, at June 14, 2008 4:26 AM  

Very mature vomen!

By Anonymous Website Design Kent, at June 05, 2009 5:28 PM  

Great support article for Carp installation. If you have many pages, updating all links to php can be time consuming. Enabling php on non php pages can be a snitch using this information.

Carp user........
Web Site Design Kent

Post a Comment


This page is powered by Blogger. Isn't yours?

Warning: include_once(/www/templates/gt/parts/blogs/carptips/second.php) [function.include-once]: failed to open stream: No such file or directory in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 466

Warning: include_once() [function.include]: Failed opening '/www/templates/gt/parts/blogs/carptips/second.php' for inclusion (include_path='.:/usr/local/lib/php') in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 466

Warning: include_once(/www/templates/gt/parts/blogs/carptips/third.php) [function.include-once]: failed to open stream: No such file or directory in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 473

Warning: include_once() [function.include]: Failed opening '/www/templates/gt/parts/blogs/carptips/third.php' for inclusion (include_path='.:/usr/local/lib/php') in /www/gt/docs/carp/tips/2005/06/displaying-feeds-in-non-php-pages.php on line 473