Forum Moderators: coopster
I added the following line to the .htaccess file in my root directory:
AddType application/x-httpd-php .php .htm .html
It worked beautifully, but the rest of the site crashed with the following error & obviously I've had to reinstate the previous .htaccess file. I don't know which versions of apache & php are being used here, but I could find out.
Parse error: parse error, unexpected T_STRING in /home/**directories**/calendar.html on line 1
thanks again!
[edited by: jatar_k at 6:48 pm (utc) on Feb. 24, 2005]
[edit reason] removed url [/edit]
AddType application/x-httpd-php .php .htm .html;
thanks again
waggamama
it is because you are telling apache that .htm and .html is application/x-.....
try
AddType application/x-httpd-php .php;
instead
if that dont work, try no terminator... I dont use .htaccess so idk if your supposed to use them. but i thing that .htm and .html crap messed u up
as to the line you should use in .htaccess, the line you had originally is right
AddType application/x-httpd-php .php .htm .html
this will cause any files with the extensions .php .htm and .html to be parsed by php. This line is not to be terminated by a semicolon.
full htaccess tutorial
[httpd.apache.org...]
alright so with that cleared up we need to look at your error. i would write the file like so
<?php
include "navscript.php";
include "header.php";
include "navigation.php";
include "footer.php";
?>
make sure there are no blank lines above your <?php tag. You don't need to have the <?php?> for each individual include.
This <?php means turn the php parsing on.
This?> means turn the php parsing off.
so, as long as you still have php code then leave the parser going. See what that change to your .htaccess and this for your file does and then report back when you wake up. ;)
The most common scenario for this error
Parse error: parse error, unexpected T_STRING in /home/**directories**/calendar.html on line 1
is forgetting a $ or forgetting to put // before your comments.
I see what you mean about the php code in my file but what happens if I don't want all the includes to be called together? E.g. I want to call navigation at the top of the file and then footer at the bottom. Should I leave the php parsing on for the entire page or is it more efficient to turn it on and off several times?
<?php
include "navscript.php";
include "header.php";
include "navigation.php";
?>
<p>fancy html stuff here
<?php
include "footer.php";
?>
jump in and out of php as much as you like. It depends on what your page is doing, if you need to spit out a big chunk of straight html then drop out of the parser. If you need to build an html table in a loop then just echo your rows, or not.
It really depends on your personal style and what a script is doing.