Home >Backend Development >PHP Tutorial >PHP connection to sql2008 (Practical)_PHP tutorial

PHP connection to sql2008 (Practical)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:46:091052browse

As for the method of php connecting to mssql2008, you can refer to other articles on my blog for introduction
If you operate
We can first read the help file in the downloaded plug-in. It is very detailed but it is in English
You can also get the manual online. The convenient address for the Chinese version is
http://technet.microsoft.com/zh-cn/library/hh352126(SQL.10).aspx
http://msdn.microsoft.com/zh-cn/library/hh352126(v=SQL.10).aspx


Below is a simple test of mine
All basic functions are available

Including connecting to the database, executing SQL, getting the number and content of records, and getting the number and content of fields


php-sql2008

$serverName = "(local)"; //Database server address

$uid = "sa"; //Database username

$pwd = "Admin777"; //Database password

$db_name="DB_FMDISP"; //Database name

$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>$db_name);

$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn == false)

{

echo "Connect error!";

Die( print_r( sqlsrv_errors(), true));

}

//Execute sql statement

$stmt = sqlsrv_query($conn, "SELECT TOP 1000 [uid],[uname],[upwd],[udate],[enable] FROM [DB_FMDISP].[dbo].[tb_user]", array(), array ( "Scrollable" => SQLSRV_CURSOR_KEYSET ));

if($stmt === false )

{

echo "Error in executing query.";

Die( print_r( sqlsrv_errors(), true));

}

//Get the number of records

$row_count = sqlsrv_num_rows($stmt);

if ($row_count === false){

echo "nget row errorn".'
';

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn