Getting data from Sql Server. Call php from commandl ine is differance to from browser -
my code is
$dsn = 'dblib:dbname=aad;host=mssql'; $dbh = new pdo($dsn, $user, $password); $query = "aad..usp_client_code_list_uas 'wh04', 'accs'"; $stmt = $dbh->query($query); while ($row = $stmt->fetch(pdo::fetch_assoc)) print_r($row);
my scheme ubuntu. when phone call command line php test.php output is
เอบอส จำกัด
but when phone call browser i'm getting
????? ?????
how prepare it? help me pls.
try one:
define('charset', 'iso-8859-1'); define('replace_flags', ent_compat | ent_xhtml); $dsn = 'dblib:dbname=aad;host=mssql'; $dbh = new pdo($dsn, $user, $password); $query = "aad..usp_client_code_list_uas 'wh04', 'accs'"; $stmt = $dbh->query($query); while ($row = $stmt->fetch(pdo::fetch_assoc)) { echo htmlspecialchars($row, replace_flags, charset); }
good luck!
php sql-server browser command-line pdo
No comments:
Post a Comment