ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Pound Sign (£) Does Not Convert Correctly DB2 SQL -> MySQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pound Sign (£) Does Not Convert Correctly DB2 SQL -> MySQL

    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:

    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>";
        }


    Poddys Rambles On

  • #2
    Re: Pound Sign (£) Does Not Convert Correctly DB2 SQL -> MySQL

    Check out the CCSID setting for the jobs I think that the job runs as the default CCSID from the system value (if that is 65535 it could be the problem)

    Chris...

    Comment

    Working...
    X