We are using Recently, someone asked me if I want to use php to connect to the sql server database when developing using PHP. I told them that they can use the mssql_connect($host,$username,$password) method to connect PHP to the Sql database.
Actually, you can find this function by searching online, and many people use it. However, a friend reported that mssql_connect() is not defined in the system, which is strange. I have always used it this way. I suspected that his PHP version was too low to support it. He told me that it was php5.14. There is no problem with this version.
What’s the problem? I tried various methods later but couldn't solve it.
Later, suddenly, I remembered that PHP functions are all configured by PHP.INI. Could it be that the support for sql server was not enabled? At first glance, it turns out there is none.
Solution to PHP connecting to Sql database:
1. Find php.ini in the apache2 directory and open it.
2. Find ";extension=php_mssql.dll", remove the ";" in front of it, save
3. Restart the apache service (note that it must be restarted, many people often forget it without knowing it Reason)
Use mssql_connect() to connect to the sql server to completely connect PHP to the Sql database.