Escolar Documentos
Profissional Documentos
Cultura Documentos
Connecting PHP to Microsoft SQL Server on Linux - Blog - Dave James Miller
Here is how to get PHP 5.2 on Linux (speci cally Debian/Ubuntu) talking to a Microsoft SQL Server
database:
2. Restart Apache
3. Test FreeTDS
If it connects, its working. Note: If you try to SELECT an NTEXT or NVARCHAR column you may get
an error saying Unicode data in a Unicode-only collation or ntext data cannot be sent to clients
using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. That is expected and will be xed
in the next step.
1
2
3
4
[yourserver]
host = your.server.name
port = 1433
tds version = 8.0
1/2
Connecting PHP to Microsoft SQL Server on Linux - Blog - Dave James Miller
5. Test FreeTDS using server
name
7/23/2016
If you try to select something, you shouldnt get the Unicode error now because you speci ed
tds version = 8.0.
6. Test in PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if (!$link)
die('Unable to connect!');
if (!mssql_select_db('yourdatabasename', $link))
die('Unable to select database!');
mssql_free_result($result);
https://davejamesmiller.com/blog/connecting-php-to-microsoft-sql-server-on-linux
2/2