Bonjour .. Je sais que mon problème est très fréquent dans le monde du web mais une solution adéquate à mon problème reste introuvable.
Grâce à ce code j'importe un fichier XML à ma base de données :
<?php
$data = array();
try
{
$bdd = new PDO('mysql:host=localhost;dbname=archive', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
function add_person( $first, $middle, $last, $email )
{
global $data, $bdd;
if(!empty($first) and!empty($middle) and !empty($last) and !empty($email))
{ $sth = $bdd->prepare( "INSERT INTO names VALUES( 0, ?, ?, ?, ? )" );
$sth->execute(array( $first, $middle, $last, $email ) );
$data []= array(
'first' => $first,
'middle' => $middle,
'last' => $last,
'email' => $email
);
}}
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$first = "";
$middle = "";
$last = "";
$email = "";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind !
null ) $index $ind;
if ( $index
1 ) $first $cell->nodeValue;
if ( $index
2 ) $middle $cell->nodeValue;
if ( $index
3 ) $last $cell->nodeValue;
if ( $index
4 ) $email $cell->nodeValue;
$index += 1;
}
add_person( $first, $middle, $last, $email );
}
$first_row = false;
}
}
une fois dans ma base les accents deviennent des éé . Oui oui cela me rend malade!
Alors ma base est en utf8_general_ci, ma table aussi et les colonnes aussi !!
Je ne vois vraiment pas où est le problème!
Aidez moi svp
et merciii d'avance