PDA

View Full Version : php "include" problem. Help needed, please


ultimatehandyma
August 4th, 2005, 01:45 PM
Hi Everyone.

I have just finished doing a index for my site where people can advertise. I sorted the areas by county first then by major towns/cities. This meant that I have over 240 pages for the towns, I did these in PHP as I have some affiliate links on my site and I thought it would be good to use the php include line-<?php include("example.htm"); ?>

This way If I changed the file example.htm it would change on all 240 pages that I had the php include line on. But when I have changed the included file, nothing at all has changed on the pages and after closer inspection I can see that the script for the affiliate banners has been copied onto each page, despite me using the PHP include line!!!!!

Here is the link to the suppliers index (http://www.ultimatehandyman.co.uk/suppliersindex.htm)

Now if I want to change an affiliate banner I have to edit 240 pages individually!

Is there anyone that can tell me where I went wrong? and is there anything I can do to correct it, without editing all 240 pages!

Thanks in advance

ultimatehandyman (http://www.ultimatehandyman.co.uk/)

MishY
August 4th, 2005, 05:41 PM
Hi,

Do you own your own server ?

All the pages I can see on your site are all ending in ".htm". Unless Apache (or IIS) is told to parse htm files for PHP then PHP code will not execute.

Have you confirmed that PHP is running properly on the server ?

Create a file called test.php and put this in it:


<?
phpinfo();
?>


Upload it to your server and then bring up the page in your browser. Does that output the PHP config ?

Please post back and we'll see what we can do.

ultimatehandyma
August 4th, 2005, 06:29 PM
Hi Mishy


Thanks for the reply, I am off to work soon so may not be able to try out your test file until saturday or sunday.

Most of the pages on my site are HTM but the pages in my suppliers directory are PHP files like this one-bracknell suppliers (http://www.ultimatehandyman.co.uk/bracknellsupliers.php)

I think PHP is running correctly as I have PHPBB installed on my site and it runs with no problem at all, apart from when I try to update it to a newer version and mess things up completely lol.

Thanks for the post, I will try it as soon as I get time.

Thanks

ultimatehandyman

MishY
August 4th, 2005, 06:33 PM
ultimatehandyman,

The problem really looks like you need to setup your server to parse htm files for PHP.

You cannot run php code in htm files unless you setup your server to do so.

If this page is a good example of where the include should be working http://www.ultimatehandyman.co.uk/suppliersindex.htm then PHP is not executing should be the first thing you check.

MrMikl
August 11th, 2005, 10:30 PM
Did you get your PHP problem resolved, I found out that the versions of PHP are many and different on sites and books. What works on my server is require("config.php"); include('name'); and include("name"); simply wont pass. I hope you get the problem solved.
MrMikl