Leanah_as
Leanah_as

Reputation: 99

i get a Fatal error when i try to connect mssql using php in wampserver

I'm using Wampserver (32bit & php 5.4I)2.4 *in windows 64bit*, will i install the 32bit becuse i need a connection to the MSSQL which required that as i know so far.

i downloaded the Microsoft Visual C++ and the php is a thread safe so i added the two .dll files (php_pdo_sqlsrv_54_ts , php_sqlsrv_54_ts*) to the C:\wamp\bin\php\php5.4.16\ext*, then added them in the php.ini ( extension=php_pdo_sqlsrv_54_ts and extension=php_sqlsrv_54_ts), then restarted the wampserver finally i gett an error says "Fatal error: Call to undefined function sqlsrv_connect()" the code that i use is :

<?php
$serverName = "serverName\instanceName"; 
$connectionInfo = array( "Database"=>"DB NAME");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

could anyone tell me what did i do wrong to cause this error?

Upvotes: 0

Views: 258

Answers (1)

Birla
Birla

Reputation: 1174

  1. Use phpinfo() to see if the extension was loaded correctly.
  2. If yes, see the error log for any issues encountered when starting apache (W*A*MP).
  3. If yes, then the extension binary is wrong or you forgot to enter the file extension (.dll on Win, .so on Linux) in the php.ini.

Upvotes: 0

Related Questions