First, mssql extension is not available anymore on Windows with PHP 5.3 or later.
Of course, PHP provides us with an alternative: under Windows you can use the sqlsrv extension provided by Microsoft (official website), and under Linux you can use the freetds extension (official website).
Installing sqlsrv is very simple, skip it. Today we will talk about the installation of freetds:
1. Download freetds, unzip it, enter the source file directory and execute:
view plain
./configure --prefix=/usr/local/freetds --with-tdsver=7.2
make
make install
Important Tip 1: What you need to pay attention to in this step is --with-tdsver, the tds version corresponding to sql server2005 is 7.2 (it seems that everything you can find on the Internet is written as 8.0)
2. Recompile php
view plain
./configure --prefix=/usr/local/php --with-mssql=/usr/local/freetds/
make
make install
Important note 2: As for the other configurations of configure, I think you understand. Only the compilation options of mssql are listed here.
3. Configure /usr/local/freetds/etc/freetds.conf (create if there is no egServer72 node, modify if there is)
view plain
# A typical Microsoft server
[egServer72]
Host = sql server 2005 server name
port = 1433
tds version = 7.2
At this point, all preparations have been completed. Now you can restart apache and use php to call sql server 2005!
Important tip three: When calling the mssql_connect function, it should be noted that its first parameter should be egServer72 (that is, the configuration in freetds.conf), not the IP of the sql server! ! ! Remember! ! !
Author xiaodao1986