P? H? P? ? 5 ?.? 3? ? Connected? S? Q? L? ? S? E? R? V? E? R? ? 2? 0? 0? 8? ? R? 2

Source: Internet
Author: User

My machine is:
XP SP3
Web SQL Server 2008 developer Apache 2.2.2
Python 5.3
Starting from 5.3, PHP will no longer provide MSSQL. dll, so to connect PHP to SQL Server 2008/2012, you must use SQL Server for PHP 2.0/3.0 provided by Microsoft.

Note that php5.4 must be 3.0 and Microsoft SQL Server 2012 native client. PHP official help
Http://php.net/manual/zh/sqlsrv.requirements.php
Microsoft drivers 3.0/2.0 for PHP for SQL Server
Http://www.microsoft.com/en-us/download/details.aspx? Id = 20098

Microsoft SQL Server 2012/2008 native client (if you have installed SQL Server, the corresponding version should be available by default)
Http://msdn.microsoft.com/zh-cn/aa937733

2005 or 2008, version 9, 10 http://go.microsoft.com/fwlink? Linkid = 239647 x86 version for 11 http://go.microsoft.com/fwlink? Linkid = 239648x64
My 5.3 is directly using the Wamp integration environment,

Http://www.wampserver.com/en/

Install the dynamic Connection Library in the ext directory of php5.3

 
4. Start Wamp and enable the php_sqlsrv _ *. DLL to be used (if you do not see this, refer to the following)

 
(You can also modify it in PHP. INI)

;;;;;;;;;;;;;;;;;;;;;;; Dynamic extensions ;;;;;;;;;;;;;;;;;;;;;;
 
Extension = php_pdo_sqlsrv_53_ts_vc9.dll

Extension = php_sqlsrv_53_ts_vc9.dll

Use phpinfo ()

<? PHP

Header ("Content-Type: text/html; charset = UTF-8 ");
$ Servername = "192.168.50.5, 1433"; // local
$ Database = "dadiands ";
$ Uid = "sa ";
$ Pwd = "123456 ";
Try {
$ Conn = new PDO ("sqlsrv: Server = $ servername; database = $ Database", $ uid, $ PWD );
$ Conn-> setattribute (PDO: attr_errmode, PDO: errmode_exception );
} Catch (pdoexception $ e ){
Die ("error connecting to SQL Server". $ E );
}
Echo "connected to SQL Server \ n ";
$ Query = 'select Top 2 * From c_host ';
// $ Query = 'select count (*) from c_host ';
$ Stmt = $ Conn-> query ($ query );
// $ COUNT = $ stmt-> fetchcolumn (0 );
// If (is_array ($ count) {echo 'xx';} else {echo $ count ;}
/// Echo $ count;

/// Var_dump ($ stmt-> fetchall (PDO: fetch_assoc ));

While ($ ROW = $ stmt-> fetch (PDO: fetch_assoc )){
Var_dump ($ row );
}
$ Stmt = NULL;
$ Conn = NULL;
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.