Page 1 of 1

Parsing - I think

Posted: Thu Jun 30, 2005 5:10 am
by summitweb
Hello:

I have an HTML page which has two include statements within it.

The HTML code is below.

Code: Select all

<html xmlns=&quote;http://www.w3.org/1999/xhtml&quote;>
<head>
<meta http-equiv=&quote;Content-Type&quote; content=&quote;text/html; charset=iso-8859-1&quote; />
<title>Untitled Document</title>
</head>

<body>
<?php
$include = &quote;http://www.interactiverates.com/quickquote.html?custid=3310&quote;;
include($include);
?>
<br />
<br />
<?php include(&quote;http://www.interactiverates.com/rates.html?custid=3310&quote;); ?> 
</body>
</html>
=========
The result of running this HTML page is a blank page.

The result should appear as in the following link:
http://www.summitwebcrafters.com/informed/test.php.

=========

I do not understand why the include statements work when I have the file named as test.php but it doesn't work when I have the file named as test.html.

The company which provides the information generated by the two URL's in the include statement state that the statements should work as an .html document.

Any ideas?

Thanks.

Posted: Thu Jun 30, 2005 5:34 am
by Chris Corbyn
Yes they work "as" an HTML document in the sense that the output is no different or special compared with plain HTML.

But in order for PHP to run on the server the file must be named with a .php extension.

Your file is simply being read a plain HTML by the server and so the PHP inside it isn't being parsed.

If you really really must use a .html extension then you have to do some things with either .htaccess or httpd.conf but we wont go down that road unless needed ;)

Posted: Thu Jun 30, 2005 5:47 am
by summitweb
Thank you for the reply.

I'm not sure what I'm going to do. One of those include statements needs to be placed on the home page.

When a person types a web address, the browser automatically loads the index.htm/html page. In order for the includes to work, I would need to rename my index page to index.php. The browser won't load the .php page automatically.

Did that makes any sense?

Posted: Thu Jun 30, 2005 5:53 am
by Chris Corbyn
Perfect sense... so are you saying that your host offers PHP but won't load index.php by default? That's bad... very bad..

Anyway... you can fix it if your host uses apache by creating a file named ".htaccess" (starts with a dot) in the folder the file will be loaded from. Open it an enter just the following line...

Code: Select all

DirectoryIndex index.html index.htm index.php
Rename your index.html file to index.php and make sure there are no index.html or index.htm files in the same directory since they will load by default before any PHP will.

Fingers crossed... it will now load your index.php file ;)

Posted: Thu Jun 30, 2005 6:07 am
by summitweb
Thanks. I will give it a try.

Will the search engine spiders crawl a page with a PHP extension? This site is being optimized and I want to make sure that the spiders will crawl the content of the index.php file.

Posted: Thu Jun 30, 2005 6:13 am
by Chris Corbyn
summitweb wrote:Thanks. I will give it a try.

Will the search engine spiders crawl a page with a PHP extension? This site is being optimized and I want to make sure that the spiders will crawl the content of the index.php file.
Of course :) It's still HTML that they are reading ;)

Posted: Thu Jun 30, 2005 6:53 am
by summitweb
Thank you so very much for all your help. I will try removing my index.html pages and renaming to .php and hopefully it'll work.

Posted: Thu Jun 30, 2005 7:03 am
by summitweb
Hi,

I thought I would let you know that by renaming my files from index.html to index.php, my browser was able to default to index.php and I got the info as I need it.

Thank you so very much. You were a tremendous help! :D 8O