0

I'm trying to read uft-8 unicode from my database onto my webpage.

Encoding (according to database): utf8_unicode_ci (using 000webhost)

contents of the fields: ! http://puu.sh/4DY1O.png As you can see the second cell contains an "é" at the end. When I read this out via SQL query I get this on my website: http://puu.sh/4DY4t.png

Here's the query I'm using:

// Create connection
   $con = mysqli_connect("host","username","passwd","database");

// Database Connection Check
   if (mysqli_connect_errno($con)) {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      break;
   }

   // Print Ploegsamenstelling
      // Print Spelers
         $result = mysqli_query($con,"SELECT voornaam, naam FROM lowavolLeden WHERE ploeg_id='5' ORDER BY voornaam, naam");
         while($row = mysqli_fetch_array($result)) {
            echo "<dt>" . $row['voornaam'] . " " . $row['naam'] . "</dt>";
         }
         echo "<br />";
      //Print Trainer
         $result = mysqli_query($con,"SELECT voornaam, naam FROM lowavolTrainers WHERE ploeg_id='5'");
         while($row = mysqli_fetch_array($result)) {
            echo "<dt><strong>Trainster: </strong>" . $row['voornaam'] . " " . $row['naam'] . "</dt>";
         }

// Close Connection
mysqli_close($con);

Thanks for the help!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Thomas De Marez
  • 668
  • 8
  • 24
  • relevant (almost dupe): http://stackoverflow.com/questions/279170/utf-8-all-the-way-through-my-web-application-apache-mysql-php – mvp Sep 30 '13 at 09:57

1 Answers1

0

This is from my head :) replace YOURCHARSET HERE with the charset you are using on your server :) (using Iconv)

 $result = mysqli_query($con,"SELECT voornaam, naam FROM lowavolLeden WHERE ploeg_id='5' ORDER BY voornaam, naam");
$naam = iconv("UTF-8", YOURCHARSET HERE, $row['naam'])
$voornaam = iconv("UTF-8", YOURCHARSET HERE, $row['voornaam'])
while($row = mysqli_fetch_array($result)) {
    echo "<dt>" .$voornaam . " " . naam  . "</dt>";
}
echo "<br />";
//Print Trainer
$result = mysqli_query($con,"SELECT voornaam, naam FROM lowavolTrainers WHERE ploeg_id='5'");
$naam = iconv("UTF-8", YOURCHARSET HERE, $row['naam'])
$voornaam = iconv("UTF-8", YOURCHARSET HERE, $row['voornaam'])

while($row = mysqli_fetch_array($result)) {
    echo "<dt><strong>Trainster: </strong>" .$voornaam. " " . $naam . "</dt>";
}