Here is my configuration:
I have a virtual server set up called TestServer1. On it is installed SQL Server 2005, IIS, and PHP. In SQL Server I have set up a Guest account with password "password". It has full privledges (which I know is dumb but I'm ruling out a permissions error with this.)
On my desktop I have SQL Server 2005 client tools installed.
Using the PHP code below I load the PHP file on my desktop (or on the server) in IE and die and get the message "Couldn't connect to sQL Server on TestServer1".
But from my desktop using SQL Server's Management Studio, using the Guest account I can connect just fine and view my test database.
Any ideas as to where my point of failure is?
<title> PHP Test Script </title>
$myServer = "TestServer1";
$myUser = "guest";
$myPass = "password";
$myDB = "PHPTest";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT fname, lname, city";
$query .= "FROM testData";
$query .= "WHERE city='Springfield'";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
//close the connection