php5.3 can not connect the MSSQL database solution, Php5.3mssql
In this paper, the solution of php5.3 cannot connect MSSQL database is described. Share to everyone for your reference. The specific analysis is as follows:
Since php5.3, the system does not support mssql_connect This function is connected, I used to say that I can use the COM interface to implement, and now I introduce the solution php5.3 can not connect MSSQL database another method.
Under Windows systems, the MSSQL extension is not supported for versions above PHP5.3.
First http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx click get it download SQLSRV20.EXE.
Unzip the file into the PHP extension folder ext, open php.ini at the end of the add:
Copy the Code code as follows: [Php_pdo_sqlsrv]
Extension=php_pdo_sqlsrv_53_nts_vc6.dll
[Php_sqlsrv]
Extension=php_sqlsrv_53_nts_vc6.dll
After saving, restart Apache, and attach a simple example of PHP connection, the code is as follows:
Copy the Code code as follows: <?php
$serverName = "(127.0.0.1)";
$connectionInfo = Array ("UID" = "root",
"PWD" = "root2010",
"Database" = "master");
$conn = Sqlsrv_connect ($serverName, $connectionInfo);
if ($conn)
{
echo "Connection ESTABLISHED.N";
}
Else
{
echo "Connection could not being ESTABLISHED.N";
Die (Print_r (Sqlsrv_errors (), true));
}
?>
I am using the wamp5.1 integrated installation package, the tests that were done on Windows Server 2008, php5.4 the above version of the test did not succeed.
If you are using this extension to connect to SQL Server version 2005 and above (such as SQL Server 2008), you will also need to install SQL Server Native on the machine first client:http:// Download.microsoft.com/download/0/e/6/0e67502a-22b4-4c47-92d3-0d223f117190/sqlncli.msi
This extension provides PHP with a new set of functions that begin with SQLSRV_, which are referenced in the following function:
Copy the Code code 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
More detailed instructions can be found in just the self-extracting file that has a Sqlserverdriverforphp.chm help file that you can find open after clicking on the API Reference node.
Also see a ODB connection mode, the code is as follows:
Copy the Code code as follows: $dbhost = ';
$dbuser = "; Your MSSQL user name
$dbpass = "; Your MSSQL code.
$dbname = "; The name of your MSSQL library
$connect =odbc_connect ("Driver={sql Server}; server= $dbhost;D atabase= $dbname "," $dbuser "," $dbpass ");
$sql = "SELECT * from Content";
$exec =odbc_exec ($connect, $sql);
while ($row = (Odbc_fetch_array ($exec)))
{
$row [' ID ']//? Fetch field Value
...
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/933598.html www.bkjia.com true http://www.bkjia.com/PHPjc/933598.html techarticle php5.3 cannot connect the solution of MSSQL database, php5.3mssql the solution that php5.3 can not connect MSSQL database in this case. Share to everyone for your reference. The specific analysis is as follows ...