How to solve the problem that PHP cannot connect to the SQL Server database

Source: Internet
Author: User

Source: http://www.study-code.com/php-delphi/php/70546.htm

Recently, someone asked me if I want to use PHP to connect to the SQL Server database during php development. I told them that mssql_connect ($ host, $ username, $ password) can be used for connection.

In fact, you can find this function once you search the Internet. Many of them use it. However, my friend reported that the system does not define mssql_connect (), which is strange. I have always used it. I suspect that his PHP version is too low to support it, he told me php5.14. This version does not have a problem.

Where is the problem? I tried a variety of methods later and couldn't solve it.

Later, I suddenly remembered that PHP's functions were all configured by PHP. ini. Will it fail to enable SQL server support? At first glance, no.

Solution:

1. Find PHP. ini in the directory of apache2 and open it.

2. Find "; Extension = php_mssql.dll", remove the previous ";", and save

3. Restart the apache service (Be sure to restart it. Many of them often forget it, but do not know why)

Use mssql_connect () to connect to SQL Server.

 

Related Article

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.