I am running Windows 7 (32 bit) and have installed Apache 2.2 and PHP 5.3.1 thread safe. I installed these seperately as I previously tried a WAMP bundle and did not like it as I found it problematic. The apache and PHP components run fine. I have the apache port set to 7777 and when I go to the URL http://localhost:7777/phpinfo.php the PHP Info appears. Also I can create a basic PHP Hello World and it can be viewed in the browser. I need to connect to a SQL Server 2005 instance to learn PHP on a project. I have downloaded the SQLSRV30.EXE and extracted the files and placed the DLL's php_pdo_sqlsrv_53_ts.dll and php_sqlsrv_53_ts.dll in the folder C:\PHP\ext then placed the following entries in the php.ini file
extension=php_pdo_sqlsrv_53_ts.dll extension=php_sqlsrv_53_ts.dll
Restarted Apache and in the phpinfo list it does not state any SQL Server attributes. And when I try to run the example below the browser states - Fatal error: Call to undefined function sqlsrv_connect(). I have found several examples on stackoverflow but they concern using wamp. What am I doing wrong here please?
Update: I actually installed NetBeans for PHP and created a new project with the same code below in the index.php page and when I run it the error is the same
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Check SQL Server Connection</title>
</head>
<body>
<?php
$serverName = "IT90334\SQLEXPRESS";
$connectionInfo = array('Database' => 'AdventureWorks');
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn) {
echo "Connection Established.<br />";
} else {
echo "Something went wrong while connecting to MSSQL.<br />";
die(print_r(sqlsrv_errors(), true));
}
?>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire