I'm trying connect to MS SQL Server with PHP with DBX. with a phpinf(), i can note that dbx is enabled:
dbx
dbx support enabled
dbx version 1.0.0
supported databases MySQL ODBC PostgreSQL Microsoft SQL Server FrontBase Oracle 8 (oci8) Sybase-CT.
But when i try connect, appear this error:
Warning: dbx: module 'mssql' not loaded.
this is the code:
dbx_connect("mssql","host","database","user","password");
Any idea to solve this?
My recommendation is going to be not using DBX. It's a dead module and should not be used by modern code.
DBX was removed from standard PHP in version 5.1. If you have it installed, that means someone went out of their way to install it as a PECL module, or you're using a very old PHP version.
On the requirements page, it states:
To be able to use a database with the dbx-module, the module must be either linked or loaded into PHP
The only module DBX supports for talking to MS SQL Server is the old mssql_
family. That extension is no longer available in Windows PHP versions 5.3 or later.
If you're on Linux, and are using an OS-provided PHP release, you might be able to get it installed. Look for php-mssql
or php53-mssql
. It might also show up when you search package descriptions for "FreeTDS." If no packages are available, you may be in for a world of pain. Getting mssql_
compiled and installed is quite a bear.
However, there are much better alternatives.
The goal of DBX was to present a unified set of functions that let you speak to a multitude of the existing PHP database adapters. That role is now filled by PDO. If you're on Windows, you should use PDO_SQLSRV. If you aren't on Windows, you could use PDO_DBLIB (which uses the same backend as the mssql_
family) or PDO_ODBC. If you've never used PDO before, there are a few good tutorials. That one is targeted at MySQL users, but it still applies to other databases.
If the code you've written is only ever intended to run on MS SQL Server, and you're running PHP on Windows, then you could also consider writing it using the sqlsrv_
family of functions instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With