求php连接MSSQL数据源码份,有注释最好~~
展开全部
$conn = mssql_connect('127.0.0.1','用户名','密码') or die('连接不成功'); //连接服务器
mssql_select_db('数据名',$conn) or die('数据库不存在'); //选择数据
mssql_query("sql语句");//查询数据
连接需要服务器php_mssql.dll扩展,php.ini中启用extension=php_mssql.dll (适合php5.3之前版本,php5.3或之后用SQLServerDriverForPHP驱动)
SQLServerDriver连接:
$serverName = "(local)";
$connectionInfo = array( "Database"=>"数据库名", "UID" => '用户', "PWD" => '密码');
$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));
}
.....................
sqlsrv_close( $conn);
http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx
mssql_select_db('数据名',$conn) or die('数据库不存在'); //选择数据
mssql_query("sql语句");//查询数据
连接需要服务器php_mssql.dll扩展,php.ini中启用extension=php_mssql.dll (适合php5.3之前版本,php5.3或之后用SQLServerDriverForPHP驱动)
SQLServerDriver连接:
$serverName = "(local)";
$connectionInfo = array( "Database"=>"数据库名", "UID" => '用户', "PWD" => '密码');
$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));
}
.....................
sqlsrv_close( $conn);
http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询