0

I am quite new to setting php with ms sql server.

I downloaded the php version php-5.6.31-nts-Win32-VC11-x86 and downloaded the drivers for ms sql db to the ext folder in the php path.

I can see the files php_sqlsrv_56_nts.dll and php_sqlsrv_56_ts.dll

I have also modified the php.ini file to extention=php_sqlsrv_56_nts.dll and extension_dir ="ext"

I have some php files in path1

I opened the command prompt in the php folder and executed the following command: php -S localhost:8085 -t path1

The server is setup succesfully. However, I get an error Fatal error:

Call to undefined function sqlsrv_connect() in the line

$conn = sqlsrv_connect($servername, $connectionInfo);

Did I miss anything here?

saeed
  • 2,477
  • 2
  • 23
  • 40
Ajmal Moideen
  • 170
  • 1
  • 6
  • 17
  • 1
    check `phpinfo()` and make sure it's in there – delboy1978uk Sep 21 '17 at 12:57
  • When viewing the output from `phpinfo()`, also check near the top to see the actual path of the php.ini it used. There may be multiple ini files used in different contexts, such as CLI vs web. I'm not sure on Windows if there's an .ini that might take precedence when using the `php -S` server. – Michael Berkowski Sep 21 '17 at 13:04
  • It points to the correct ini file. How do I understand whether the extensions have been loaded correctly or not from the phpinfo.php page? – Ajmal Moideen Sep 21 '17 at 13:48
  • Possible duplicate of [Fatal error: Call to undefined function sqlsrv\_connect()](https://stackoverflow.com/questions/22015179/fatal-error-call-to-undefined-function-sqlsrv-connect) – miken32 Sep 21 '17 at 23:21
  • phpinfo() says it is pointing to the correct ini file. – Ajmal Moideen Sep 22 '17 at 02:50
  • I also tried to get the list of extensions loaded using `print_r(get_loaded_extensions());` code. This doesn't return the dll loaded for sqlserver(). Is there anything that I have missed? – Ajmal Moideen Sep 22 '17 at 12:20

1 Answers1

0

I understood my error. I added both the dll files in php.ini and this worked extention=php_pdo_sqlsrv_56_nts.dll extension=php_sqlsrv_56_nts.dll;

Ajmal Moideen
  • 170
  • 1
  • 6
  • 17