I am getting sql server connection error with xampp - php

Actually, I followed all the paths in the document, but I still get an undefined sql error while connecting.
I followed these paths respectively.
1-Microsoft® ODBC Driver 11 for SQL Server® install
2-Microsoft Drivers for PHP for SQL Server this version: 7.3
dll files in the corresponding folder
php / ext
php_pdo_sqlsrv_73_nts_x64.dll
php_pdo_sqlsrv_73_ts_x64.dll
then I restarted xampp, i viewed phpinfo
But when I run my file the error I get is:
Fatal error: Uncaught Error: Call to undefined function
sqlsrv_connect() in
what could be missing?

You need to enable PHP Driver for SQL Server, but not PDO version. Function sqlsrv_connect() and all sqlsrv_ functions are part of the SQLSRV driver.
To enable the SQLSRV driver, you need to modify the php.ini by adding the appropriate line to the extension section - php_sqlsrv_73_nts_x64.dll or php_sqlsrv_73_ts_x64.dll depending on the PHP version.
Of course, as an option, you may try to rewrite your code using PDO (PHP Data Objects). The PDPO_SQLSRV part of the driver is installed on your WEB server.

Related

PHP 7 SQLSRV driver doesn't load

I been trying to connect to my local MSSQL database using php.
Right now I am stuck at installing the correct drivers for php to work with MSSQL.
SO far I have:
1.Downloaded and setup Xampp
2.Downloaded the the SQLSRV driver at:https://github.com/Microsoft/msphpsql/releases/tag/v4.3.0
3.Placed the files within my extension_dir and double checked php.ini varible to point to the correct folder.
4. Manually added
extension=php_pdo_sqlsrv_71_ts.dll
extension=php_sqlsrv_71_ts.dll
to the list of extension within php.ini.
Yet I am still seeing the same Fatal error and a boolean checking if the driver has been loaded returns false:
bool(false)
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in
C:\xampp\htdocs\firsttest\api.php:9 Stack trace: #0 {main} thrown in
C:\xampp\htdocs\firsttest\api.php on line 9
Did I miss a step? I have been following different guidelines and some of them seemed outdated. I tried installing ODBC driver and the installer said that I had a higher version. Therefore I expect that shouldn't cause any problems.
By double checking everything I realize that Xampp always install as a 32-bit application. Therefore i should've taken the 86-bit version of the .dll files instead of the 64-bit.
Atleast this solved the problem for me.

Uncaught Error: Call to undefined function mysqli_connect() when connecting to the database [duplicate]

This question already has answers here:
How can I enable the MySQLi extension in PHP 7?
(8 answers)
Closed 6 years ago.
I get an error when trying to connect to my database with mysqli on PHP 7.0 and PHP 7.1
PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/mywebsite/public_html/connection.php:7
$conn = mysqli_connect($DBhost,$DBuser,$DBpass,$DBname);
First check, if mysqli is enabled: phpinfo()
The mysqli PHP extension is not installed on your server. Contact to your server administrator.
OR
If you host the server yourself, in the php.ini file remove the semicolon in front of the extension extension=php_mysqli.dll.
Hope, this helps you
I would recommend using PHP PDO for database connection. Its got better performance and I think the code looks better.
But to speak on your error, it looks like php doesnt have a reference to mysqli library. Did you explicitly install the php-mysql package? Its also possible that the environment variable path is not pointing to the right location on the filesystem.
Your php not instaled mysql connector ,
for install linux :
sudo install php-mysqli
Happens when php extensions are not being used by default.
In your php.ini file, change
;extension=php_mysql.dll
to
extension=php_mysql.dll.
The mysqli PHP extension is not installed on your new server.
Contact to your server administrator.
If you host the server yourself, in the php.ini file remove the semicolon in front of the extension extension=php_mysqli.dll

php sqlsrv driver is not being recognized

my PHP Version is 5.6 and I ve already downloaded the driver for the sqlsrv extension and placed it in the ext/ directory, as well as modified the php.ini with the new extensions.
I still get the following error when trying to connect to my database
Fatal error: Call to undefined function sqlsrv_connect() in C:\inetpub\wwwroot\db.php on line 12
Is there anything that i've missed?
Did you change Edit System Variable and Windows extensions ?
You can find here : http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-and-configure-php
Good luck..

Call to undefined function sqlsrv_connect() in C:\wamp\www\Webs\client.php on line 7

Am using windows 8 pro, Wamp server (php V5.3.5, apache V2.2.17), Sql server 2005 express editon. I have downloaded the sqlsrv drivers and extracted them into the php extention folder (C:\wamp\bin\php\php5.3.5\ext), have also update the php.ini file by adding the extentions
extension=php_sqlsrv_53_ts_vc6.dll
extension=php_pdo_sqlsrv_53_ts_vc6.dll
I used this two after series of try and error on all the dll file, it was this two that come up with no error, when restarting the wamp server
This is the connection line of code;
$con = sqlsrv_connect('TAQUATECH\SQLEXPRESS') or die("cannot connect");
It came up with the following error;
Fatal error: Call to undefined function sqlsrv_connect() in
C:\wamp\www\Webs\client.php on line 7
pls, i need somebody to help me on this, i will really appreciate
Sorry if too late to answer, but I had the same error, and I found out that Wamp Server 64bit does not support SQL Server Connection, you must install a 32bit version of wamp server.
For those using 64-bit systems (OS, WAMP, MSSQL), these 64-bit drivers can serve them and fix the error:
Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www...
Drivers SQLSRV x64:
http://robsphp.blogspot.in/2012/06/unofficial-microsoft-sql-server-driver.html
You'll need to install and enable sqlsrv on your web server. Have a look at the installation page on the official PHP website.
Installation of Microsoft Drivers 3.0 for PHP for SQL Server will fix this issue. Also try this PHP Manual.
EDIT :
The most recent version of the driver is available for download here:
» SQLSRV 3.0 download. If you need support for PHP 5.2 and/or PHP
compiled with VC6, use the 2.0 release of the driver: » SQLSRV 2.0
download.
Source
Yap, I have gotten a work-around;
The problem was, running the php script using apache server on my system, I stoped the wamp server and configure fastCGI for PHP using IIS 7, You can get a video tutorial Here
http://www.iis.net/learn/application-frameworks/running-php-applications-on-iis/set-up-fastcgi-for-php.
It simple and nice, now i can connect to both sql server 2005 and 2008
My PHP Details
Version => 5.3.5
Compiler => MSVC6 (Visual C++ 6.0)
SqlSrv Driver => php_sqlsrv_53_ts_vc6.dll
use 32 bit PHP Version.
enable below one of them in php.ini
[PHP_PDO_SQLSRV_53_NTS]
extension=php_pdo_sqlsrv_53_nts.dll
[PHP_SQLSRV_54_NTS]
extension=php_sqlsrv_54_nts.dll
[PHP_SQLSRV_53_NTS]
extension=php_sqlsrv_53_nts.dll
[PHP_PDO_SQLSRV_54_NTS]
extension=php_pdo_sqlsrv_54_nts.dll
thease dll version you can downlowd online

sqlsrv_connect() not found

I'm working on a project that uses the SQL Server Driver for PHP, and want to upgrade the driver to the new version (2.0), because I need some of the functions that have been implemented there.
I replaced the old .dll in the php/ext directory and restarted the web server. But now I receive the following error:
Fatal error: Call to undefined function sqlsrv_connect() in E:\ProjekteExtern\hades\_apl\classes\sql\sqlsrv.class.php on line 34
The phpinfo() output shows sqlsrv, just like with the previous version.
Does anybody know why I'm getting this error or have any ideas to solve this problem?
For those still having errors with PHP and Microsoft SQL Server using PHP SQL, check the web server's log (Apache, IIS, etc). I have just found out that WampServer x64 is not compatible with PHP SQL Server Driver, so I'm installing the 32-bit version back again.
UPDATE:
for WampServer 2.2, PHP is compiled thread-safe and with VC++ 9.0, so it works using either
php_pdo_sqlsrv_53_ts_vc9.dll
or
php_sqlsrv_53_ts_vc9.dll

Categories