我不断收到此错误:PHP PDO:Charset=UTF8:在 dsn 字符串中指定了无效的关键字字符集。
我的代码是这样的
function ConnectToSQLAndGetDBConnSTRVar() {
try {
$dbname = "irina";
$serverName = ".\SQLEXPRESS";
$username = "USERNAME";
$pw = "PASSWORD";
$dbh = new PDO ("sqlsrv:server=$serverName;Database=$dbname;charset=utf8","$username","$pw");
return $dbh;
}
catch (PDOException $e) {
print "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
}
我如何写 utf8 并不重要。UTF8 或 UTF-8 或 utf-8 它们都不适合我。所以我该怎么办,请帮助我。