PHP _php tutorial for connecting MS SQL Server under Linux

Source: Internet
Author: User
Tags sybase microsoft iis
Ask questions a few days ago to do a very strange project, I developed a set of China Unicom SGIP Protocol, SP-terminal short Message service software, provide unicom 130 SMS service. The system is under Windows 2000, the database is Microsoft SQLServer2000, and it has been running for a while. and recently because to provide some information on the web for short message users, you need to read and write SQL Server database from the Web, the SQL Server database is the best partner should be Microsoft IIS ASP Server script, but my company always think iis+ The stability and security of ASP is not satisfactory, hoping to read and write SQL Server with PHP script under Linux.
Analysis of the problem is that PHP script read and write SQL Server is not a problem, in Apache for Windows and Windows IIS can work very well, generally can be connected via ODBC or SQL Server client, This is all ready-made under Windows. But there is no existing ODBC and SQL Server Client under Linux, and we need to install it ourselves.
Resolution one, related software FreeTDS Source: ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/freetds-0.53.tgz This software is able to connect MS with Linux and UNIX. SQL Server and Sybase databases.
 Second, installation configuration step the first step: Compile and install FreeTDS: Get freetds-0.53.tgz post CP freetds-0.53.tgz/tmp/. (Copy FreeTDS package to/tmp directory) cd/tmp (enter directory) tar zxvf freetds-0.53.tgz (unzip) CD freetds-0.53 (into the unpacked directory)./configure–prefix=/usr/local /freetds--with-tdsver=7.0 gmake (Generate makefile, I tried, make can also) gmake install (install) about it configure I want to say,--prefix=/usr/local/ FreeTDS refers to the installation of/usr/local/freetds this directory,--with-tdsver=7.0 refers to the installation of TDS version 7.0 (the most open is that I did not add this compilation parameter, the result is compiled by default to 5.0. 5.0 the port to connect to the database is 4000, not SQL Server 1433) Step two: Recompile PHP4./configure [--with-apxs--with-mysql ...]--with-sybase=/usr/local/ FreeTDS (Note that it is Sybase) make make install step three: Configure FreeTDS vi/usr/local/freetds/etc/freetds.conf specific configuration See examples in this file: (Typical configuration) [ SQL Server] host = SQL_SERVER_NAME_OR_HOST_IP (your SQL Server machine name or IP address) port = 1433 TDS Version = 7.0 In this configuration file you can configure Windows domain login or SQL Server account login two ways fourth step: Configure the php.ini file found; extension=mssql70.so will comment; extension=mssql70.so Fifth step: Establish database connection in PHP $link =mssql _connect ("SQL Server", $your _username, $your _password) or Die ("can ' t connect to Database"); Echo $link; Run the above script in the browser, if you get an LInk number so congratulations, you've already configured, if it appears, call to undefined function:mssql_connect () That means look closely at the installation configuration process above to see which step you did not correct.
Note: The SQL Server name is the host parameter defined in/usr/local/freetds/etc/freetds.conf, if you write an IP address, it is the IP address.
Other database operations reference related MSSQL functions note that Chinese is not supported in SQL statements!!! Sixth step: Debug If you can not connect, find in the FreeTDS configuration file, dump file =/tmp/freetds.log This line, comment out the previous semicolon, then execute the test script, see/tmp/ Freetds.log file, it can tell you a lot of error information to help you troubleshoot problems.

http://www.bkjia.com/PHPjc/445274.html www.bkjia.com true http://www.bkjia.com/PHPjc/445274.html techarticle ask questions a few days ago to do a very strange project, I developed a set of China Unicom SGIP Protocol, SP-terminal short Message service software, provide unicom 130 SMS service. This set of systems ...

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.