PHP链接SQL Server2008能用
连接字符串
<?php
$conn=mssql_connect('localhost','sa','sa') ;
mssql_select_db('MaterialDataBase',$conn) ;
?>
但是SQL Server2005 Express怎么办,连接字符串怎么写?(机器上同时装有SQL Server2008和SQL Server2005 Express,并且有多个实例),由于用于商业用途不能用盗版,只能改用SQL Server2005 Express
连接字符串
<?php
$conn=mssql_connect('localhost','sa','sa') ;
mssql_select_db('MaterialDataBase',$conn) ;
?>
但是SQL Server2005 Express怎么办,连接字符串怎么写?(机器上同时装有SQL Server2008和SQL Server2005 Express,并且有多个实例),由于用于商业用途不能用盗版,只能改用SQL Server2005 Express
php 操作 mssql 应用微软提供的sqlsrv扩展,而非第三方的mssql
否则高版本的mssql的性能不能得到发挥,也不能防范基于mssql2000的 SQL攻击
<?php
$conn=mssql_connect('MSSQLSERVER','sa','sa') ;
mssql_select_db('MaterialDataBase',$conn) ;
?>
是这个意思吗
/*
Connect to the local server using Windows Authentication and specify
the AdventureWorks database as the database in use. To connect using
SQL Server Authentication, set values for the "UID" and "PWD"
attributes in the $connectionInfo parameter. For example:
$connectionInfo = array("UID" => $uid, "PWD" => $pwd));
*/
$serverName = "(local)";
$connectionInfo = array( "Database"=>"AdventureWorks");
$conn = sqlsrv_connect( $serverName, $connectionInfo);if( $conn )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}//-----------------------------------------------
// Perform operations with connection.
//-----------------------------------------------/* Close the connection. */
sqlsrv_close( $conn);
?>