为什么我的SBS 2011 IIS网站中只有一个连接到MySQL而另一个不连接?

I have multiply websites configured and setup on a SBS 2011 virtual machine.

The default wwwroot website connects to MySQL without any trouble with the host set to 'localhost'. But the second website that has it's own seperate directory location along side the wwwroot directory can not access the MySQL Database with 'localhost' as its host connection.

Anyone have any ideas why the default site connects to the MySQL Database but the second website does not?

Okay here is my directory structure.

inetpub

../websites

../../website1

../wwwroot

<?php

$db_username="username"; $db_password="password"; $database="database"; $db_host="localhost";

mysql_connect("$db_host", "$db_username", "$db_password") or die("cannot connect");  mysql_select_db("$database")or die("cannot select Database");

?>

When ever I run this code in the wwwroot directory it works but not when I execute this code in the website1 directory.

UPDATE!!!

So it seems that it is not my connection to the MySQL database that is the problem it is the include php function.

So my problem is now why does the php include function work within the wwwroot folder and not the website1 folder?

Thanks

Foo

Okay I think I have solved the problem myself. I have been programming with php for several years now and have just realized that I need to follow and remember all the new changes.

Too many mistakes for me to list but thanks anyway people for reading my problem.

Ensure all PHP code is encased in

 <?php ?>

and not

 <? ?>

It might work on one server but it won't work on servers running the latest version of PHP 5.6