我正在尝试将MS SQL Server 2012与php连接。我的操作系统是Linux Red Hat,我使用的是PHP 5.5.7版本。这是我的连接功能:
{
"sources": ["Web", "Tests"]
}
当我运行此功能时,它会显示错误: function connect_ms_sql()
{
try {
$hostname = "xxx";
$port = 111;
$dbname = "xxx";
$username = "xxx";
$pw = "xxx";
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname", "$username", "$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
unset($dbh);
}
。我该怎么办呢?我尝试使用FreeTDS,同样的错误。请帮帮我!