I'm back looking at this again after a period of being distracted with other things.
I have a clean install of Windows 2008 R2 64-bit.
PHP 5.3.8 installed (php-5.3.8-nts-Win32-VC9-x86.msi)
"extension=php_pdo_sqlsrv_53_nts_vc9.dll" and "extension=php_sqlsrv_53_nts_vc9.dll" enabled in php.ini (and the dll files placed in in the "ext" folder).
php.php loads find and shows php is running.
I have a small script that attempts to connect to the SQL server (SQL2000 running on windows 2003 32-bit server), and display a few rows of data.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="EN">
<head>
<title>PHP Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$ctsref = $_GET['callref'];
?>
<div class="popup-content">
<h1>Job Documents for <?php echo $ctsref;?></h1>
<?php
$serverName = "SQLSERVERNAME";
$connectionInfo = array( "Database"=>"DBNAME", "UID"=>"username", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "select * from linked_documents where ld_link_reference = '$ctsref'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
$fileCounter = 0;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
$fileCounter++;
?>
<p>
<?php
$dt = $row['LD_DateTime'];
$ldcat = $row['LD_Category'];
$ldembed = $row['LD_Embedded'];
echo $dt->format('d/m/Y H:i:s');
echo " | ";
echo $row['LD_Category'];
echo " | ";
?>
<?php
if ($ldembed == "1" && $ldcat == "Photo") {
?>
<a target="_blank" href="view_photo.asp?docid=<?php echo $row['LD_ID'];?>">VIEW PHOTO</a>
<?php
} elseif ($ldembed == "0" && $ldcat == "Photo") {
?>
<a href="view_docs.php?docid=<?php echo $row['LD_ID'];?>">VIEW PHOTO</a>
<?php
} else {
?>
<a href="view_docs.php?docid=<?php echo $row['LD_ID'];?>">VIEW DOCUMENT</a>
<?php
}
?>
</p>
<?php
}
if ($fileCounter == 0) {
?><p>No documents have been uploaded.</p><?php
}
sqlsrv_free_stmt( $stmt);
?>
</div>
</body>
</html>
When i load the page (with the appropriate query string) i get the following error:
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )
The error suggests i need to install the ODBC driver, so i downloaded and installed both "Microsoft ODBC Driver 11 for SQL Server" and "Microsoft ODBC Driver 13 for SQL Server". I could only install the 64-bit versions of both of those. Rebooted, tried again and still the same error.
I'm at a loss as to what else is required to make this work.
Looking back on the thread, it seems I may need to change the PHP version?
We have the potential to change the Windows 2008 R2 to Windows 2012, but the SQL server will always remain SQL2000 32-bit for the long-term foreesable future.