Jump to content

Recommended Posts

I'm trying to connect to my SQL Server 2008 DB using the MS driver but I'm having some issues. Any ideas?

Here is my test connection using Microsoft's driver

<?php
/* Specify the server and connection string attributes. */
  $serverName = "(local)\SQLj";

/* Get UID and PWD from application-specific files.  */
$uid = file_get_contents("D:\PHP\u.txt");
$pwd = file_get_contents("D:\PHP\ppp.txt");
$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>"AdventureWorks");

/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Unable to connect.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Query SQL Server for the login of the user accessing the
database. */
$tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false )
{
     echo "Error in executing query.</br>";
     die( print_r( sqlsrv_errors(), true));
}

/* Retrieve and display the results of the query. */
$row = sqlsrv_fetch_array($stmt);
echo "User login: ".$row[0]."</br>";

/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>

The error

 This extension requires the Microsoft SQL Server 2011 Native Client. Access the following URL to download the Microsoft SQL Server 2011 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2011 Native Client. Access the following URL to download the Microsoft SQL Server 2011 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 ) )

 

PHP Info results


pdo_sqlsrv
pdo_sqlsrv support enabled 

Directive Local Value Master Value 
pdo_sqlsrv.client_buffer_max_kb_size 10240 10240 
pdo_sqlsrv.log_severity 0 0 

Link to comment
https://forums.phpfreaks.com/topic/250974-php-installmssql-driver-issue/
Share on other sites

Have you tried going to the link in the error message?

Yes I have. I did notice that the message wants be to download "Microsoft SQL Server 2011 Native Client ODBC driver for x86", but I am running 64bit Windows 7 and MSSQL Express Edition with Advanced Services (64-bit).

The x86 driver wont install but the x64 package was already installed.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.