I am having trouble writing MySQL data (column of type TEXT, length around 4000 chars) into MS Access(column of type MEMO). I connect to mdb Access database using PDO:
function i($name) {
return iconv("utf-8","windows-1250",$name);
}
try{
$db = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=mydb.mdb;Uid=");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo $e->getMessage();
}
//....fetching mysql data ....
//updating
$upd_query = $db->prepare("update SKz set Name = :Name, Desc2 = :Desc2 WHERE ID = :ID");
$upd_query->execute(array(
':Name'=>i($r['name']),
':Desc2'=>i($r['desc2']),
':ID'=>(int)$r['id']
)
);
The operation looks ok , no errors, but after I read the record back from Access, there are random illegal characters at the end of the inserted string (column Desc2), for example Řl 9 h“� h“� €�ô
I tried some methods like cleaning text with iconv, preg_replace, doesnt work. MySql encoding UTF8, Access has Windows-1250.
How do I clean illegal chars and prevent inserting them? Any ideas?
(testing on XAMPP pack, Windows server 2003 64bit)