Using PHP to connect SQL Server solutions under Linux
Source: Internet
Author: User
server|sqlserver| Resolution steps:
First step: Compile and install FreeTDS:
cd/tmp/
Tar xzf freetds-*.tgz
CD freetds-*/
./configure--prefix=/usr/local/freetds
Gmake
Gmake Install
Step two: Compile and install PHP4
./configure--with-mysql--with-sybase=/usr/local/freetds .... (The following parameters differ according to their respective needs)
#例子 (My compilation parameters):./configure--prefix=/usr/local/php--with-mysql--with-apxs2=/usr/local/apache/bin/apxs--with-zlib-- WITH-JPEG-DIR=/USR--with-png--with-freetype--with-ttf--enable-gd-native-ttf--WITH-GD-- Enable-dio--with-sybase=/usr/local/freetds--with-dom
Make
Make install
Step Three: Configure FreeTDS
Vim/usr/local/freetds/etc/freetds.conf
Specific configuration See the description in the file
Cases:
[MYSERVER2K]
Host = 192.168.0.1
Port = 1433
TDS Version = 8.0
And you can comment out the unused JDBC intervals.
Step Fourth: Configure the php.ini file
Modify the related MSSQL interval configuration, default can not be modified
Step Fifth: Test
Mssql_connect ("192.168.0.1:1433", "sa", "");
mssql_select_db (' TestDB ');
$sql = "SELECT * from test_table WHERE condition = ' condition ';";
$result = Mssql_query ($sql);
$row = Mssql_fetch_array ($result);
Print_r ($row);
?>
No surprises, you will see the results you expect.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service