0

I need to convert database from Oracle into UTF-8 to insert into Mysql.

The "é" are "?"

All my Mysql are into UTF-8 general-ci

The database is already good shown on the website but when i import it from oracle i can't because of the "'" or "é", "à"...

<?php
if (isset ( $_POST ["importer"] )) {

$connect = odbc_connect("bd_dev", "bsa_data", "data");
include ("include/connexion.php");
$choixImmeubleAImporter = $_POST ['select_importImmeuble'];

$queryAmenagementExt = "SELECT N_NUME_IMME, I_ESPA_EXTE, C_GERA_ESPA, C_CHEM_EXTE, I_ESPA_VERT, C_CONT_ESPV, C_ETAT_ECLA, 
                C_TYPE_CLOT, C_ETAT_CLOT, C_ETAT_JEUX, C_ETAT_PP, I_ESPA_CANI, I_POIN_COLL, 
                I_ESPA_ARBR, I_ESPA_BANC, I_ESPA_POUB, I_ZONE_POTA, D_LAST_MODI, R_UTIL_MODI, 
                L_AMEN_COMM from bsa_data.i10_amex where N_NUME_IMME = $choixImmeubleAImporter";

$resultAmenagementExt = odbc_exec($connect, $queryAmenagementExt);

while(odbc_fetch_row($resultAmenagementExt)){
        $N_NUME_IMME= odbc_result($resultAmenagementExt, 1);
        $I_ESPA_EXTE= odbc_result($resultAmenagementExt, 2);
        $C_GERA_ESPA= odbc_result($resultAmenagementExt, 3);
        $C_CHEM_EXTE= odbc_result($resultAmenagementExt, 4);
        $I_ESPA_VERT= odbc_result($resultAmenagementExt, 5);
        $C_CONT_ESPV= odbc_result($resultAmenagementExt, 6);
        $C_ETAT_ECLA= odbc_result($resultAmenagementExt, 7);
        $C_TYPE_CLOT= odbc_result($resultAmenagementExt, 8);
        $C_ETAT_CLOT= odbc_result($resultAmenagementExt, 9);
        $C_ETAT_JEUX= odbc_result($resultAmenagementExt, 10);
        $C_ETAT_PP= odbc_result($resultAmenagementExt, 11);
        $I_ESPA_CANI= odbc_result($resultAmenagementExt, 12);
        $I_POIN_COLL= odbc_result($resultAmenagementExt, 13);
        $I_ESPA_ARBR= odbc_result($resultAmenagementExt, 14);
        $I_ESPA_BANC= odbc_result($resultAmenagementExt, 15);
        $I_ESPA_POUB= odbc_result($resultAmenagementExt, 16);
        $I_ZONE_POTA= odbc_result($resultAmenagementExt, 17);
        $D_LAST_MODI= odbc_result($resultAmenagementExt, 18);
        $R_UTIL_MODI= odbc_result($resultAmenagementExt, 19);
        $L_AMEN_COMM= 'null';
}

$db->exec ("INSERT INTO i10_amex
        SET         i10_amex.n_nume_imme = '$N_NUME_IMME',
                    i10_amex.i_espa_exte = '$I_ESPA_EXTE',
                    i10_amex.c_gera_espa = '$C_GERA_ESPA',
                    i10_amex.c_chem_exte = '$C_CHEM_EXTE',
                    i10_amex.i_espa_vert = '$I_ESPA_VERT',
                    i10_amex.c_cont_espv = '$C_CONT_ESPV',
                    i10_amex.c_etat_ecla = '$C_ETAT_ECLA',
                    i10_amex.c_type_clot = '$C_TYPE_CLOT',
                    i10_amex.c_etat_clot = '$C_ETAT_CLOT',
                    i10_amex.c_etat_jeux = '$C_ETAT_JEUX',
                    i10_amex.c_etat_pp = '$C_ETAT_PP',
                    i10_amex.i_espa_cani = '$I_ESPA_CANI',
                    i10_amex.i_poin_coll = '$I_POIN_COLL',
                    i10_amex.i_espa_arbr = '$I_ESPA_ARBR',
                    i10_amex.i_espa_banc = '$I_ESPA_BANC',
                    i10_amex.i_espa_poub = '$I_ESPA_POUB',
                    i10_amex.i_zone_pota = '$I_ZONE_POTA',
                    i10_amex.d_last_modi = '$D_LAST_MODI',
                    i10_amex.r_util_modi = '$R_UTIL_MODI',
                    i10_amex.l_amen_comm = '$L_AMEN_COMM'");

echo '<script type="text/javascript">window.location = "index.php"; </script>';

} ?>

B.A
  • 29
  • 3
  • https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Matt Jun 07 '17 at 15:09
  • Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use [`odbc_prepare()`](http://php.net/manual/en/function.odbc-prepare.php) with bound parameters. – Alex Howansky Jun 07 '17 at 15:14

0 Answers0