Hey. I haven't done much php work - so am quite confused as to why this code doesn't work, here's an example: Inside example.html, instead of having the footer coded in html, I want it so I only ever have to edit 1 file - the php file. So I have this code in example.html <div class="footer"> <?php include('footer.php'); ?> </div> Code (markup): In footer.php, I have this: <p><a href="link1.html">Link 1</a> | <a href="link2.html">Link 2</a> | <a href="link3.html">Link 3</a> </p> Code (markup): I have uploaded both files to the server - however, where the footer should appear, I just get a white blank space... Does anyone have any idea why it's not working? Thanks!
You can't have php inside .html page, unless you set your server to handle html as php. What you can do is rename your example.html to example.php then it will work.
Ah, okay. The file is in the same directory. So how do I get my server to handle php as html or vice versa? Thanks
check you file calling footer.php is in the same directory as it and also that the file calling footer is a .php another thing to check would be permissions, this can sometimes stop you from "including" other files.
to handle php as html, you need to have mod_rewrite on your server and make use of CRR on your htaccess.
Just change the file from example.html to example..php. Your webhost should support PHP files without any additional effort. Try it.
So you still want to use .html instead of rename it to php? if so, create a .htaccess file in the same directory and paste this code in. AddType application/x-httpd-php .html Code (markup):
Hello. The server is a Linux server, and supports .htaccess, I have added the line AddType application/x-httpd-php .html Code (markup): to the .htaccess file, but now when I try to navigate to example.php - firefox pops up the download box as if it is downloading the example.html file to my computer...
Man, just change the file extension to .php. You don't need to make .html parsed as PHP for the whole site. Its overkill. Best delete that line.
Are you suggesting I change all pages to .php - wouldn't this mean I have to recode the entire site? Thanks
Are you doing your entire site over? You can do it pretty easily without changing webserver settings. And its the first I have seen you mention doing the entire site. The first post was "why isn't this working with one file".
Hey. I am just starting the site. Got around 14 pages done - using html, fully x-html/css compliant. What's your idea? Cheers
No, unfortunately not When I go to index.html - Firefox pops up the download box and asks me to open/save the index.html file, it is the same for every file. Ahh, this sucks
Well you are putting the nav links to a php include file right? Do you have lots of other links internally? Have you already edited the files to add those? Vbot's suggestion above for the AddType should have worked though.
Yeah, it should have worked for AddType - but it doesn't Should I just go round changing every instance of .html to .php? Thanks
Yes, I did change it again and I get the same problem. If I save the file as .php it works, but not as .html ? When it is .html, firefox asks me to open or save the file on my computer, not on the server. Meh