"fff","ConnectionPooling"=>'','UID '=>'sa','PWD ..."/> "fff","ConnectionPooling"=>'','UID '=>'sa','PWD ...">

Home  >  Article  >  Backend Development  >  PHP connects to sql server database

PHP connects to sql server database

巴扎黑
巴扎黑Original
2016-11-22 10:51:222213browse

Install the sqlsrv module of php
//Local connection
$serverName = "CX95DLISVW4C6TKaaa";//Computer name instance name
$connectionInfo = array("Database"=>"fff","ConnectionPooling"=>'' ,'UID'=>'sa','PWD'=>'123');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "Connect Failed! ";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$query=sqlsrv_query($conn,"select * from dbo.fdsf");
while($ row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}

//Remote connection
$serverName = "192.168.1.5";
$connectionInfo = array ("Database"=>"CIA","ConnectionPooling"=>'','UID'=>'sa','PWD'=>'360kad.com');
$conn = sqlsrv_connect( $ serverName, $connectionInfo);
if( $conn == false)
{
echo "Connection failed!";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$ query=sqlsrv_query($conn,"select * from CodeSiteTaker_Model");
while($row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}


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