1

I try to save some Greek letter in MySQL with PHP but the characters are saved like this: "μαÏτίοÏ"

On my HTML page i have se meta charset on "utf8" and also I have create the db in MySQL like this "....CHARACTER SET utf8 COLLATE utf8_unicode_ci". Please find below my php db connetction code:

<?php
$con=mysqli_connect("localhost","user","password","customers" );

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
mysql_query('set character set UTF8');
mysql_query("SET NAMES 'utf8'");
}

Any idea what might be wrong?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Leonidas
  • 45
  • 1
  • 1
  • 8
  • 1
    Possible duplicate of : http://stackoverflow.com/questions/279170/utf-8-all-the-way-through/279279#279279 – CD001 Jun 19 '15 at 09:57
  • Oh - then again; you're mixing `mysql_` and `mysqli_` extensions; those `mysql_query` statements won't work with the `mysqli_connect` so the database connector charset isn't being set. – CD001 Jun 19 '15 at 09:58
  • 1
    Thank you for noticing that mysql_ and mysqli are together! I simply add "mysqli_set_charset($con,"utf8");" and it worked! – Leonidas Jun 19 '15 at 10:06
  • Glad you managed to sort it - it's often better that way, you're more likely to remember it now ;) – CD001 Jun 19 '15 at 10:15

0 Answers0