When you connect to SQLServer, SQLServerDriverforPHP supports SQLServer authentication. when you use SQLServer authentication to connect to SQLServer... when you connect to SQL Server, SQL Server Driver for PHP supports SQL Server Authentication. when using SQL Server Authentication to connect to SQL Server, you must consider the following points.
You must enable SQL Server hybrid authentication on the Server. when trying to establish a connection, you must set the UID and PWD connection Attributes. the UID and PWD must be mapped to a valid SQL Server user and password.
Note:The password that contains the right braces (}) must be escaped using another right braces. for example, if the SQL Server password is "pass} word ", the value of the PWD connection attribute must be set to "pass} word ".
When using SQL Server Authentication to connect to SQL Server, take the following preventive measures. the following code is a simple example:
$ Uid, "PWD" => $ pwd, "Database" => "AdventureWorks"); $ conn = sqlsrv_connect ($ serverName, $ connectionInfo ); if ($ conn = false) {echo "cannot connect to the database. "; die (print_r (sqlsrv_errors (), true) ;}$ tsql =" select convert (varchar (32), SUSER_SNAME ())"; $ stmt = sqlsrv_query ($ conn, $ tsql); if ($ stmt = false) {echo "query error. "; die (print_r (sqlsrv_errors (), true);} // open source code phprm.com $ row = sqlsrv_fetch_array ($ stmt); echo" login user :". $ row [0]; sqlsrv_free_stmt ($ stmt); sqlsrv_close ($ conn );
Address:
Reprinted at will, but please attach the article address :-)