SQL server error
Posted: Mon Jun 08, 2009 1:05 pm
Hello all,
I'm a first time poster and a complete WAMP noob.
Anyways, I'm trying to set up a intranet using APache and SqlSErver express 2005.
Apache is set up, but I'm having trouble accessing the database.
Here's the error I got when I typed dbinfo.php into my address window:
Fatal error: Call to undefined function mssql_connect() in C:\WebServer\Apache2\htdocs\phpinfo.php on line 8
Here's my code:
I installed the sql libaries php_sqlsrv_ts.dll and php_sqlsrv.dll in the C:\WebServers\PHP\ext folder and rebooted the computer.
When I run a simple php script, it works, so I know Apache is picking up PHP. But how can I make the PHP script recognize 'mssql_connect' and other functions?
Thanks again to all for any help.
Mike
I'm a first time poster and a complete WAMP noob.
Anyways, I'm trying to set up a intranet using APache and SqlSErver express 2005.
Apache is set up, but I'm having trouble accessing the database.
Here's the error I got when I typed dbinfo.php into my address window:
Fatal error: Call to undefined function mssql_connect() in C:\WebServer\Apache2\htdocs\phpinfo.php on line 8
Here's my code:
Code: Select all
<?php
$myServer = "SQLEXPRESS\\ComputerName";
$myUser = "sa";
$myPass = "password";
$myDB = "MyDb.mdf";
//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 * ";
$query .= "FROM Employees ";
//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
mssql_close($dbhandle);
?>
When I run a simple php script, it works, so I know Apache is picking up PHP. But how can I make the PHP script recognize 'mssql_connect' and other functions?
Thanks again to all for any help.
Mike