PHP configuration database connection MSSql

Original link: http://www.cnblogs.com/SteadyMan/archive/2011/06/15/2081172.html

If you implement a PHP and MySQL links, PHP and MSSQL link is actually very simple;
support MSSQL local and remote links links links to local example:

the installation of MS SQLServer 2005 on the machine;


Connecting the system configuration:


1. Check the file php5.2.5 \ ntwdblib.dll following a default, then the connection can not be replaced.

Download the correct version of Ntwdblib.dll
(2000.80.194.0), Address: http://webzila.com/dll/1/ntwdblib.zip

image


2. Configure php


a, opens the extension = php.in comment symbol php_mssql.dll removed.


image


b, the open php.in mssql.secure_connection = Off to on.


image


c, the php_mssql.dll copied to the extension_dir php.in
the specified directory or the system directory system32. (There are in php php_mssql.dll compression installation package).


image


Need to restart apache after the above steps are completed.


Note: If the actual use of that mounted to the lower php iis php compressed file by hand, rather than restart the machine must iis.



3. Configure sqlserver
A running SQL Server Configuration Manager:. SQL Server
the Configuration Manager, open protocols Protocols
b allow named pipes "named pipes" and "tcp / ip."

C Right-click on the "tcp / ip", open the properties on the Properties tab. "IP Addresses"
d. in the dynamic TCP port "TCP
dynamic ports" fill 1433
E. restart SQL Server


-------------------------------------------------- ---------------------------------------------

4. use the following manner connecting MS SQL Server 2005:
Code as follows:


PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip? <PHP
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip// link database
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip
$ conn = mssql_connect ( 'localhost', 'SA', '123456');
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vipmssql_select_db ( 'gu_dde', $ conn);
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip// Query statement
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip$ Query = "the SELECT * from dde_top";
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip$ AdminResult = mssql_query ($ Query);
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip// output
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip$ the Num = mssql_num_rows ($ AdminResult);
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vipfor ($ I = 0; $ I <$ the Num; $ I ++)
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip{
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip$ Row = mssql_fetch_array ($ AdminResult);

PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vipecho ($ Row [. 1]);
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vipecho ( "a");
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip}
PHP configuration database connection MSSql - blog zhangtao_vip of - zhangtao_vip>?


MySQL can see these functions and the corresponding functions are easy to use!


-----------------------------------------------------------------------


5.FAQ FAQ:


1 error:


Fatal error: Call to undefined function mssql_connect()


solve:


Use MSSQL_ family of functions
to be used both need to be set in php.ini:
(. 1) to allow DCOM, necessary in php.ini
; com.allow_dcom before the semicolon = TRUE ";" removed.
(2) extended using MSSQL requires the php.ini
; extension = semicolon before php_mssql.dll ";" removed. (Key)

(3) confirmed the correct path extension_dir to the present machine, for example: extension_dir = "c: \ AppServ \ php5 \ ext".

(4) If you still can not find a machine error saying c: \ AppServ \ php5 \ ext \ php_mssql.dll but obviously the existence of this document.

Workaround: php_mssql.dll, ntwdblib.dll copied to the system directory \ restart the test under system32. .

(Note: not in the same directory as the top two dll files, I was c: \ AppServ \ php5 \ ext \ php_mssql.dll; c: \ AppServ \ php5 \ ntwdblib.dll)

after another set up oh remember to restart the server.


6. Other issues:


If php apache Sql Server2000 are on the same machine, access to basic no problem.


If Sql Server2000 and php machine is isolated, it is necessary to confirm the ping
sqlserver machine where the machine name can pass, such as through the barrier, modify the machine php where \ system32 \ drivers \ hosts file under the etc, add a line
machine sqlserver where the machine ip sqlserver where the machine name of the machine.


If you still can not access, you need to make sure the machine where the presence or absence of php blackout mdac. Or simply install what sqlserver client better.

Reproduced in: https: //www.cnblogs.com/SteadyMan/archive/2011/06/15/2081172.html

Guess you like

Origin blog.csdn.net/weixin_30410999/article/details/95026919
Recommended