0

I am looking to connect with SQL Server database from a php application.

$con = mssql_connect('SERVER\SQLEXPRESS2008','','') or die('Could not connect to the server!');  

But this gives me the following error

Fatal error: Call to undefined function mssql_connect()

I am using XAMPP in the windows environment and testing with the localhost.

In many examples I found that, it suggests to remove the comment(;) in front of the php_mssql.dll statement that is there in the php.ini file which resides under php folder.

THIS is one of the tutorials I found and read. The thing is when I search for the text under php.ini I dont find the php_mssql.dll and no idea why this is. Am I missing something.

Would be really grateful for any help for me to achieve this. Thanks.

2 Answers 2

2

Microsoft has released their own PHP MSSQL drivers. You might need to install them.

Sign up to request clarification or add additional context in comments.

3 Comments

HI Thanks Crontab. when I downloaded that it prompted a message saying "When prompted, enter the path to the PHP extensions directory". Does that mean php directory which resides under the XAMPP main folder?
+1 for sqlsrv which is is really a better option in a windows environment
@JibW: My guess would be wherever you find all the other php_*.dll files. I'm sorry I can't give you more than that, I haven't used PHP in Windows for a really long time.
1

To test, write this in your code:

phpinfo();
die;

Then, look over the page and see if the mssql extension is loaded. If not, edit your php.ini and uncomment the part where the mssql extension is loaded. Refresh the page and see if its loaded. If not, go back to the ini, you obviously did something wrong then.

4 Comments

I just test with phpinfo() and didn't find any mssql extension loading... Do I have to install anything after normal XAMPP installation?
You should have this line in your php.ini: extension=php_mssql.dll Of course, php_mssql should be in the extensions folder. See: php.net/manual/en/install.windows.extensions.php
HI I just uncommented that and made "mssql.secure_connection=on". Then re-started the Apache server. so when I go to browser it just give a warning saying "PHP Startup: Unable to load dynamic library C:\xampp\php\ext\php_mssql.dll - The specified module could not be found"
The module needs to be there. Check if php_mssql.dll is in the extension folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.