Joomla Asked by jamesMandatory on September 5, 2021
I am using php 7
and trying to connect to mssql server. I have this code:
<?php
$serverName = "server"; //serverNameinstanceName
$connectionInfo = array( "Database"=>"database", "UID"=>"userid", "PWD"=>"password");
$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));
}
?>
but when I open the page, I get this error
Call to undefined function SQLSRV_CONNECT()
Is it an issue with the php version or simply an additional package that I should add to my Joomla install?
As @Sharky said, it seems like your SQLSRV
extension isn't enabled. You can manually activate it by changing your php.ini
file, enabling this extension and downloading the drivers.
PHP Documentation says:
The SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The SQLSRV download comes 8 driver files, four of which are for PDO support.
You can download the file here
https://www.microsoft.com/en-us/download/details.aspx?id=20098
Once you have downloaded the file, you have to execute it. A box will prompt asking where you want to extract.
You can extract to wherever you want to and then copy to your php extension folder or you can directly extract to your PHP extension folder. Usually your extension folder lies in: your-php-folderbinphpyour-php-version
or your-php-folderbinphp
and it's called ext
. So the final path is something like this: your-php-folderbinphpext
.
To enable the dll in your php.ini
file, you have to open it, and search for Extensions
then add the dll like this:
extension=name-of-your-dll-you-downloaded-and-extracted-to-the-ext-folder.dll
Example:
extension=php_sqlsrv_81_s.dll
If that doesn't work, you can try simply extension=sqlsrv_81_s
leaving out php_ and .dll
Correct answer by Thiago Guimarães on September 5, 2021
If you Joomla work and need to access the database use Joomla functional to connect database
$db = JFactory::getDbo();
Answered by Dmitry Zar on September 5, 2021
Your issue is not related to Joomla. You are manually calling a function which does not exist on your PHP installation. This most likely means the required SQLSRV PHP extension is not enabled.
Answered by Sharky on September 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP