2017-03-14 4 views
0

Warum kann ich den Zeichensatz nicht ändern?Warum kann ich den Zeichensatz nicht ändern?

Ich benutze mssql.

... 
$dbh = new PDO("odbc:$data_source", $user, $password); 
$dbh->exec("SET NAMES utf8"); 
$dbh->exec("SET CHARACTER SET utf8"); 
... 
foreach ($dbh->query($sql) as $row) { 
    echo mb_detect_encoding($row['Name1']); 
    print $row['Name1'] . "\t"; 
} 

Und ich somthing wie folgt aus: ASCII???????? ASCII???????? ASCII?????????

+0

I DBLib unsted ODBC- und mein Problem verwenden ist gelöst –

Antwort

0

Weil Ihre Syntax falsch ist.

Lauf SET NAMES utf8 in SQL Server Management Studio direkt zurückgibt:

Msg 195, Level 15, State 7, Line 1 
'NAMES' is not a recognized SET option. 

Und läuft SET CHARACTER SET utf8 kehrt:

Msg 156, Level 15, State 1, Line 1 
Incorrect syntax near the keyword 'SET'. 
Verwandte Themen