$dbhost = ""; //服务器名字加端口名字,之间用逗号连接(,是sqlserver专有的,mysql用:冒号)
$dbuser = ""; //你的mssql用户名
$dbpass = ""; //你的mssql密码
$dbname = ""; //你的mssql库名
$connect=odbc_connect("Driver={SQL Server};Server=$dbhost;Database=$dbname","$dbuser","$dbpass");
if (!$connect)
{
die('没连接上10: ' . mysql_error());
}else{
$arr[] = $row;
}
var_dump($arr);
$dbuser = ""; //你的mssql用户名
$dbpass = ""; //你的mssql密码
$dbname = ""; //你的mssql库名
$connect=odbc_connect("Driver={SQL Server};Server=$dbhost;Database=$dbname","$dbuser","$dbpass");
if (!$connect)
{
die('没连接上10: ' . mysql_error());
}else{
$sql = "SELECT * FROM B02";
//执行语句,返回资源id
$result = odbc_exec($connect,$sql);$arr = array();
//将资源转换为数组
while( $row = odbc_fetch_array($result) ) {$arr[] = $row;
}
var_dump($arr);
exit;
连接之后的中文乱码问题的解决:
$arr = eval('return '.iconv("GB2312//IGNORE", "UTF-8", var_export($arr,true)).';');转换数组
$arr = iconv("GB2312//IGNORE", "UTF-8", $arr[0]['B0202']);转换字符串