Not sure whether to post this under PHP or SQL, but thought with more activity this would be better.
I have a PHP script that reads from a DB2 table and inserts the content to a MySQL table (it runs on the iSeries).
All works fine, except that in MySQL the "£" sign is converted to an "A" with "~" on top followed by "£", causing some columns to truncate (some customer accounts (6 chars) have "£" as the 1st character - can't change that unfortunately).
Is there any encoding I can do, either in SQL or PHP to make sure the data gets converted correctly?
The key section of the script is below:
I have a PHP script that reads from a DB2 table and inserts the content to a MySQL table (it runs on the iSeries).
All works fine, except that in MySQL the "£" sign is converted to an "A" with "~" on top followed by "£", causing some columns to truncate (some customer accounts (6 chars) have "£" as the 1st character - can't change that unfortunately).
Is there any encoding I can do, either in SQL or PHP to make sure the data gets converted correctly?
The key section of the script is below:
PHP Code:
// Read content from DB2 table and write to MySQL table
$sql = "select * from $table";
$result = db2_prepare($connDB2, $sql);
db2_execute($result);
while ($row = db2_fetch_array($result)) {
// Trim each cell
$row = array_map('trim',$row);
foreach ($row as &$cell) {
// Replace single quotes
$cell = str_replace("'","'",$cell);
}
// Implode cells
$script = "'".implode("','", $row)."'";
// Create insert statement
$sqlMy = "insert into $table values ($script)";
// Insert row
if (mysqli_query($connMySQL, $sqlMy) === FALSE) {
echo "Error on insert to $table: $sqlMy | error: ".mysqli_error($connMySQL)."<br>";
}
}
Comment