0

Does someone have an idea please? My problem is that the result that my query SQL which is in Arabic is displayed with characters like that ع٠"ÙŠÙ ‡ اÙ". While I do all:

  • for my database : cp1256_general_ci
  • column of table : utf_bin8
  • connect to data base :
// CONNEXION BDD $pdo = new PDO('mysql:host=localhost;dbname=jeu', 'root', '', array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' )); <?php require_once('inc/init.inc.php'); $req= $pdo -> query("select * from proposition "); while($data=$req -> fetch(PDO::FETCH_ASSOC)){ echo' <form action="" method="post">'; echo $data['question'].'<br />'; echo $data['id_propo'].'<br />'; echo '<input type="radio" name="rep" value='.$data["rep1"].'+'.$data['id_propo'].' />'.$data['rep1'].'<br />'; echo '<input type="radio" name="rep" value='.$data["rep2"].'+'.$data['id_propo'].' />'.$data['rep2'].'<br />'; echo '<input type="radio" name="rep" value='.$data["rep3"].'+'.$data['id_propo'].' />'.$data['rep3'].'<br />'; echo '<input type="radio" name="rep" value='.$data["rep4"].'+'.$data['id_propo'].' />'.$data['rep4'].'<br /><br />'; } echo '</form>'; ?> 
1
  • Can't say anything about cp1256_general_ci/utf_bin8, but you should also check your HTTP headers, php.ini contains "default_charset" variable that may break what you see in the browser. Commented Dec 9, 2018 at 23:03

1 Answer 1

1

You need to convert your database to utf8mb4_general_ci type instead of utf8. This is the best choice for you i think. Also check that you have applied a html header:

<meta charset=”utf-8”> 
Sign up to request clarification or add additional context in comments.

3 Comments

HTML tag is not necessary when HTTP headers contain the proper encoding.
Also check that you have correct encoding in your database tables.
Of course but practice shows that its better to add the html header.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.