Jump to content

MSSQL Connection


vagzaf

Recommended Posts

Hello all,

I am using php 8.0.8 and when i use the sqlsrv_connect(  $serverName, $connectionInfo ) function i get "undefined function". I use as an editor the Visual Studio Code.

I have modified the php.ini with extension= D:\PROGRAMS\XAMPP\htdocs\php_sqlsrv_80_ts_x64.dll ( i thing this is the mssql server driver)

Any help?

Link to comment
Share on other sites

Do you get the error actually running the script, or just as a warning in your IDE?

Your php_sqlsrv_80_ts_x64.dll probably shouldn't be in your htdocs folder.  I'm not familiar with XAMPP's layout but look for the folder where PHP is and an ext subfolder and put it there.

Link to comment
Share on other sites

I have a general question regarding this function and regarding php general

If i understand well, sqlsrv_connect() is a php function? The dll is the driver that perform a connection to an SQL server, when the specific function is called. Why when i type this function in a php editor, the php doesn't recognize it as a function? Logically php must understand this function and when i run the script, if  the driver is not installed and is not placed in the correct folder, in runtime to get an error.

Thank you

Link to comment
Share on other sites

The driver provides that function.  If the driver is not installed and working, then that function does not exist and you'd get a undefined function error when trying to run code that uses it.

Even if the driver is installed and working, it's possible your editor may not recognize it.   I'm not familiar with Visual Studio Code but it may not know that you've installed that driver and as such doesn't recognize the function.  That's why I asked if you were getting the error when actually running your code or just in your IDE.   If the error is only in your IDE, but the code works when you actually run it then you'll have to figure out why the IDE is having an issue (or just learn to ignore it).

Link to comment
Share on other sites

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.