<?
error_reporting(0);
header("content-type:text/html; charset=utf-8");
if ( trim($_SERVER['SERVER_NAME']) == "localhost" ){
//直接连接本地SQL服务器
$servername='LEO\SQLEXPRESS'; //本地SQL数据库连接名称:LEO\SQLEXPRESS
$sqlservername="sa";
$sqlserverpass="000000";
$sqlname="sqlname";
}else{
//连接远程SQL服务器
$servername="118.123.9.26";
$sqlservername="xxxxxx";
$sqlserverpass="000000";
$sqlname="sqlname";
}
$conn=mssql_connect($servername,$sqlservername,$sqlserverpass) or die("数据库链接错误,请检查!");
mssql_select_db($sqlname,$conn);
$dbcharset="utf8"; //指定数据库编码
mssql_query("SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=binary;");
?>
error_reporting(0);
header("content-type:text/html; charset=utf-8");
if ( trim($_SERVER['SERVER_NAME']) == "localhost" ){
//直接连接本地SQL服务器
$servername='LEO\SQLEXPRESS'; //本地SQL数据库连接名称:LEO\SQLEXPRESS
$sqlservername="sa";
$sqlserverpass="000000";
$sqlname="sqlname";
}else{
//连接远程SQL服务器
$servername="118.123.9.26";
$sqlservername="xxxxxx";
$sqlserverpass="000000";
$sqlname="sqlname";
}
$conn=mssql_connect($servername,$sqlservername,$sqlserverpass) or die("数据库链接错误,请检查!");
mssql_select_db($sqlname,$conn);
$dbcharset="utf8"; //指定数据库编码
mssql_query("SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=binary;");
?>