0

Sir,

I am using wamp 3.0 having php 5.6.15
SQLSERVER 2008 is installed on Windows 7 32bit.

I want to connect sqlserver with php, So I put required drives in Bin folder as

aa.png

and made some necessary changes in php.ini as

bb.png

Finally I have this connection string

<?php
$host="SERVER";
$username="sa";
$password="123456";
$db_name="at17"; 
$con=sqlsrv_connect($host, $username, $password,$db_name);

if(!$con){
die ('<script type="text/javascript">alert("Error Connecting to host")'. mysqli_connect_error($con).'</script>'); 
}
else
{
//echo( '<script type="text/javascript">alert("Connected")</script>');
}
?>

But it displays this error message

cc.png

What I am doing wrong?

Please help me

Edited by phphp

3
Contributors
2
Replies
21
Views
1 Year
Discussion Span
Last Post by maba001
0

I would assume that the SQL-Server extension is not loaded in PHP.

From the screenshots, the reason could be that you have all the
"extension=..." lines which are needed for SQL Server are in a subsection. The subsection starts according to your screenshot with [PHP_SQLSRV].

I would think that no extension lines are evaluated there.

Also do NOT include all of them. Thread safe (TS) and non thread safe (NTS) versions must match your PHP binary. So it must be one or the other.

Proposal: move two of the extension lines to the place where extensions are processed (You could move them directly below extension=php_xsl)

Use the following two:

  • php_sqlsrv.dll
  • php_sqlsrv_56_ts.dll (if your PHP is the thread safe version)
  • php_sqlsrv_56_nts.dll (if your PHP is the non thread safe version)

Restart your webserver. If it fails, post the content of the webserver error log.

Edited by maba001: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.