My table:
+--------+----------+
| U_COD | U_NAME |
+--------+----------+
| 01 | Daniel |
+--------+----------+
| 02 | Ñandu |
+--------+----------+
| 03 | Pañ |
+--------+----------+
I am connecting and doing a simple query to my firebird database like this:
$host = 'firebird:dbname=my/dir/db_test.gdb;charset=UTF8';
$password = 'mypass';
$username = 'myuname';
try{
$db = new PDO($host, $username, $password);
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e){
echo "Failed: " . $e->getMessage();
}
$getData=$db->prepare("SELECT * FROM T_TEST ORDER BY U_NAME ASC");
$getData->execute();
$arrData=$getData->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($arrData);
But when I run the file, all the values that in my database include some "ñ" letter appear as null, like this:
[
{"U_COD":"01","U_NAME":"Daniel"},
{"U_COD":"02","U_NAME":null},
{"U_COD":"03","U_NAME":null}
]
I would like to know what I'm doing wrong, let me know if you need any other details from my firebird database.
EDIT
a var_dump($arrData)
shows the values but with a "�" when there should be a "ñ" letter:
array(3) {
[0]=>
array(2) {
["U_COD"]=>
string(2) "01"
["U_NAME"]=>
string(6) "Daniel"
},
array(2) {
["U_COD"]=>
string(2) "02"
["U_NAME"]=>
string(5) "�andu"
},
array(2) {
["U_COD"]=>
string(2) "03"
["U_NAME"]=>
string(3) "Pa�"
}
}