Configuring IIS 5 to parse PHP and SSI on the same file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dbindel
Forum Newbie
Posts: 2
Joined: Sat May 25, 2002 2:54 pm
Location: San Marcos, TX
Contact:

Configuring IIS 5 to parse PHP and SSI on the same file

Post by dbindel »

I am running IIS 5.0 and I need someone to help me out with configuring application mappings.

I need to set up IIS to parse PHP files first for Server-Side Includes (SSI) and then parse the file for PHP commands. The IIS text box in which you type the location of the executable to parse the file with will not allow you to use multiple executables.

I've searched just about everywhere, and unfortunately, I can't find any place that knows how to set up multiple mappings for a single file type.

Please reply soon!

Thanks in advance,
David Bindel
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

AFAIK this isn't possible. Can't you include the files using include or require?

Mac
dbindel
Forum Newbie
Posts: 2
Joined: Sat May 25, 2002 2:54 pm
Location: San Marcos, TX
Contact:

Configuring IIS 5 to parse PHP and SSI on the same file

Post by dbindel »

ok... well then let me explain my problem with using PHP's include function:

I *would be* using PHP's include() function to include a header and footer on every page of my website, but since my implements database connections on some pages, I use code similar to the following:

mysql_select_db("my_db") or die("<p>Could not select database.</p>");

In using the die() function, it displays the message inside of it and stops all PHP processing instead of displaying a really ugly unprofessional PHP error.

But since that die() function has stopped the PHP processing, my footer file is not included at the bottom of the page.

I'm sure someone else has had this problem in the past... could you please help me?

Thanks in advance!

David Bindel
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What I've done is to create a function similar to this:

Code: Select all

function include_footer()
{
	global $path;
	include $path.'includes/footer.php';
}
where $path is the path to my domain's root directory and included the file containing the function on all pages. In order to stop the problems with the footer not being included when die() executes I then have:

Code: Select all

$connect = mysql_connect($host, $user, $pass) or die('&lt;p&gt;No database connection&lt;/p&gt;'.include_footer());
Then any other code is halted but the footer is still included.

Hope this helps,
Mac
Tiimmy
Forum Commoner
Posts: 38
Joined: Sat Apr 27, 2002 1:56 am
Location: Australia
Contact:

Post by Tiimmy »

It's not necessary to make the script end. Continue to do it if you want, but, you can do this instead:

Code: Select all

&lt;?php

function error($msg) {
    echo $msg;
}

mysql_connect($host,$user,$pass) || error('Unable to select database.');
mysql_connect($host,$user,$pass) || error(mysql_error());

?&gt;
That keeps the script running, but it also displays your error message.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Does that mean that errors arising from the fact that information in the database wasn't available will also be shown?

Edit: Answered my own question:
Yes it does, at least in my experimentation. I think that or die() makes it more dramatic anyway :) but either way you have to write a function to do something whether that's showing an error message or including a file.

Mac
Post Reply