In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to solve the problem that php does not support mssql". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
This article operating environment: windows7 system, php5.3 version, DELL G3 computer
The solution to the problem that php system does not support mssql and the solution that php5.3 cannot connect to mssql database
This paper gives an example of the solution that php5.3 can not connect to mssql database.
The analysis is as follows:
Since php5.3, the system does not support mssql_connect this function connection, before I also said that we can use the com interface to achieve, now I introduce another way to solve the problem that php5.3 can not connect to the mssql database.
Under windows system, mssql extension is no longer supported by PHP5.3 and above.
First http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx, click get it to download SQLSRV20.EXE.
Extract the file to the extended folder ext of php, open php.ini and add at the end:
The code is as follows:
[PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_53_nts_vc6.dll [PHP_SQLSRV] extension=php_sqlsrv_53_nts_vc6.dll
Restart apache after saving, and attach an example of a simple php connection, as shown below:
The code is as follows:
I used the wamp5.1 integration installation package. I did the test on windows server 2008 and the above version of php5.4 did not succeed.
If you use this extension to connect to sql server versions of Sql server 2005 or above (such as sql server 2008), you also need to install SQL Server Native Client: http://download.microsoft.com/download/0/E/6/0E67502A-22B4-4C47-92D3-0D223F117190/sqlncli.msi on your machine first.
This extension adds a series of functions starting with sqlsrv_ for php. The function references are as follows:
The code is as follows:
Sqlsrv_begin_transaction sqlsrv_cancel sqlsrv_client_info sqlsrv_close sqlsrv_commit sqlsrv_configure sqlsrv_connect sqlsrv_errors sqlsrv_execute sqlsrv_fetch sqlsrv_fetch_array sqlsrv_fetch_object sqlsrv_fetch_metadata sqlsrv_free_stmt sqlsrv_get_config sqlsrv_get_field sqlsrv_has_rows sqlsrv_next_result sqlsrv_num_fields sqlsrv_num_rows sqlsrv_prepare sqlsrv_query sqlsrv_rollback sqlsrv_rows_affected sqlsrv_send_stream_data sqlsrv_server_info
For more detailed instructions, you can find a SQLServerDriverForPHP.chm help file in the self-extracting file just now. Click the API Reference node after opening it.
In addition, look at an odb connection method, the code is as follows:
The code is as follows:
$dbhost ='; $dbuser =''; / / your mssql user name $dbpass =''; / / your mssql password $dbname =''; / / your mssql library name $connect=odbc_connect ("Driver= {SQL Server}; Server=$dbhost;Database=$dbname", "$dbuser", "$dbpass"); $sql= "select * from content"; $exec=odbc_exec ($connect,$sql); while ($row = (odbc_fetch_array ($exec) {$row ['id'] /? Take the field value... }
Undefined
Related introduction:
1. The steps for php5.3 to successfully connect to MSSQL through PDO are summarized as follows:
1. Download microsoft drivers for php for sql server (version 2.03.0, ts and nts, respectively). You can confirm that it is ts through the Thread Safety:enable in phpinfo (). For more information, please see the driver's own manual)
2. After copying the ext folder driven to the php folder, modify the php.ini extension extension=php_pdo_sqlsrv_53_ts_vc6.dll
3. Download Microsoft SQL Server 2008 R2 Native Client installation
Test the code:
Second, under windows systems, versions above PHP5.3 no longer support mssql extensions, so if you need to communicate with sql server, you need to go to http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx to download the The SQL Server Driver for PHP provided by Microsoft. This is a self-extracting file. After decompression, you will get the following files:
Php_sqlsrv_52_nts_vc6.dllphp_sqlsrv_52_ts_vc6.dllphp_sqlsrv_53_nts_vc6.dllphp_sqlsrv_53_nts_vc9.dllphp_sqlsrv_53_ts_vc6.dllphp_sqlsrv_53_ts_vc9.dllphp_sqlsrv_license.rtfSQLServerDriverForPHP.chmSQLServerDriverForPHP_Readme.htm
Among them, 52Jing 53 represents the 5.2.X and 5.3.X versions of PHP; nts means non-line and safety, ts means thread safety; and vc6 means to use Apache as Web Server,vc9 means to use IIS as Web Server.
According to your configuration, copy the appropriate DLL file to the ext folder of the php installation directory, then open php.ini and add the following statement to open the php_sqlsrv and php_pdo_sqlsrv extension:
-
[PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_53_ts_ vc6.dll[PHP _ SQLSRV] extension=php_sqlsrv_53_ts_vc6.dll
-
The 53 here means php5.3. If yours is version 5.2, change it to 52. If your PHP version is thread safe, then there should be a php5ts.dll under your PHP installation directory, corresponding to the two lines here. If it is php5nts.dll, then the above statement should be:
--
[PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_53_nts_ vc6.dll[PHP _ SQLSRV] extension=php_sqlsrv_53_nts_vc6.dll
-
There are various versions of the dll file in the compressed package, you can check it carefully.
After opening the extension, restart apache so that you can connect to sqlserver, but it is also important to note that if you do not have Microsoft SQL Server 2008 R2 Native Client installed, you must go to http://msdn.microsoft.com/en-us/library/cc296170(SQL.90).aspx to download and install it, because Microsoft needs this support for this expansion pack.
After everything is in place, you can write php code. If you download The SQL Server Driver for PHP, there is a help document in the unzipped folder. You can easily find examples. Here the webmaster introduces a simple example:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.