L'extension MSSQL est activée par la ligne extension=php_mssql.dll dans le fichier php.ini.

Pour que ces fonctions fonctionnent, vous devez compiler PHP avec --with-mssql[=DIR] , où DIR est le préfixe d'installation FreeTDS. Et le FreeTDS doit être compilé en utilisant --enable-msdblib .


Les fonctions MS SQL sont liées aux fonctions Sybase si PHP est compilé avec l'extension Sybase et sans l'extension MS SQL.

add a note add a note

User Contributed Notes 7 notes

justnshalom at gmail dot com
2 years ago
In Ubuntu Just you need to install
sudo apt-get install php5-sybase
Done ...
Connect with this keyword
mssql_connect('Your IP/localhost','username','password','database');
sbonder at outlook dot com
2 years ago
This is how I got it to work:
> Install the necessary packages for FreeTDS:
  sudo apt-get -y install freetds-bin tdsodbc unixodbc

> Configure FreeTD
  nano /etc/freetds/freetds.conf

> Create a server
        host = <server_name>
        port = 1433
        tds version = 8.0

> You can now test whether you can connect to your MSSQL Server as follows - using the tsql command line tool:
  tsql -S <createdsevername> -U <username> -P <password> -D <chosen_database>

> You should get a message that looks similar to this:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to <chosen_database>
1> quit

> Install a php extention:
apt-get install php5-sybase

> Check if mssql in available in you phpinfo
7 years ago
Linux users: I had to set the TDSDUMP and TDSCONFDUMP environment variables in my apache init script in order for freetds/mssql connections to work:

In my /etc/init.d/httpd file:
export FREETDSCONF=/usr/local/freetds/etc/freetds.conf
export SYBASE=/usr/local/freetds
export TDSDUMP=/var/log/freetds/tdsdump-apache_log
export TDSDUMPCONF=/var/log/freetds/tdsdumpconf-apache_log

Make sure apache can write to the TDSDUMP directory.

(Using FreeTDS 0.82, PHP 5.2.9)
MaxusR at yandex dot ru
1 year ago
MS SQL with dynamic ports enabled installation:

Append to freetds.conf
host = <host>
instance = <instance>
tds version = 8.0

On the server side the SQL Browser service must be running and UDP 1434 port must be open for incoming connections.
Matt Mason
9 years ago
Had a problem compiling PHP with --with-mssql=/usr/local/freetds , kept saying that it wasn't a valid FreeTDS directory...

Check that when you install FreeTDS from source, that it actually puts the required files from the source directory to where the installation directory was specified, so to fix:

cp [tds source]/include/tds.h /usr/local/freetds/include
cp [tds source]src/tds/.libs/libtds.a /usr/local/freetds/lib

{in this example I installed FreeTDS to /usr/local/freetds}

This may make it a little easier for some else too.
jonatasvenancio at gmail dot com
8 years ago
Finally i did it.

I could make the connection with MS-SQL:
1 - I downloaded the new version of ntwdblib.dll like we already saw at the others posts.
2 - I actived the php_mssql.dll in php.ini (the DLL must be in your extension dir)
3 - Restarted apache.
4 - Got my MS-SQL name instance (in my case was SQLEXPRESS because i was using MS-SQL Express Version and didn't change the default configuration).
5 - I did my connection file.

= mssql_connect("ADMIN-PC\SQLEXPRESS", "usuario", "senha") or die ("erro ao conectar");

// Admin-PC is the name of my computer and SQLExpress is the name of MS-SQL Instance).
// usuario is a user that i created on SQL server with this command.
// SP_AddLogin 'user', 'password'
// after that i used this onde SP_AddUser 'user'
// you can change fot the user you want.
// I cound't use the defaullt user of MS-SQL, but with this one the connection worked.


I hope this can help you.

Sorry for the english.
I'm brasilian.
mirko dot steiner at slashdevslashnull dot de
7 years ago
PHP msdblib niggle encountered

In configuring your new version of PHP to work with FreeTDS 0.82, you may encounter:
configure: error: Directory /usr/local/freetds-0.82 is not a FreeTDS installation directory
PHP tests for a FreeTDS installation by looking for files that FreeTDS no longer installs. To assure PHP that FreeTDS is installed, create two files where FreeTDS was installed e.g.:
$ touch /usr/local/freetds-0.82/include/tds.h
$ touch /usr/local/freetds-0.82/lib/libtds.a
The file that needs to be changed is used by autoconf when the distribution tarball is constructed. Cf. revision 1.13 of PHP source file config.m4. (12 June 2008)

To Top