Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cupy data between tables with different encoding


piernas

Recommended Posts

I'm writing a script that automatically copies relevant data from old 2.2 database to a new 2.3.4 database. 2.2 database is latin1 and new one is utf8.

// Abre dos conexiones a las bases de datos de origen y destino
    $conn = new mysqli(DESTINATION_SERVER, DESTINATION_USER, DESTINATION_PASS, DESTINATION_DB); // New database
    $conn2 = new mysqli(SOURCE_SERVER, SOURCE_USER, SOURCE_PASS, SOURCE_DB); // original database

How can I convert data from $conn2 (latin1) to $conn (UTF8) when inserting data from $conn2 into $conn?

 

I've tried:

$conn->set_charset("latin1");
$conn2->set_charset("utf8");

but it still insert weird characters. Is there a straight way to do this?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...