Use php to connect to sql server 2005 under linux_PHP tutorial

WBOY
Release: 2016-07-13 17:47:06
Original
981 people have browsed it

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478540.htmlTechArticleFirst of all, mssql extension is not available anymore on Windows with PHP 5.3 or later. Of course, php provides us with an alternative Solution: Under Windows, you can use the sqlsrv extension provided by Microsoft (...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template