php - MySQL utf8_unicode_ci -


this question has answer here:

for code below how output mysql query utf-8 support ?

<?php  $servername = "###";  $username = "###";  $password = "###";  $dbname = "###";    // create connection  $conn = mysqli_connect($servername, $username, $password, $dbname);  // check connection  if (!$conn) {      die("connection failed: " . mysqli_connect_error());  }    $sql = "select column1, column2, column3 table order column1 desc";  $result = mysqli_query($conn, $sql);    if (mysqli_num_rows($result) > 0) {      // output data of each row      echo '<table class="">';      echo "<tr><th>column1</th><th>column2</th></tr>";      while($row = mysqli_fetch_assoc($result)) {          echo "<tr><td>";          echo '<a href="' . $row['column1'] . '" target="_blank">' . $row['column3'] . '</a>';          echo "</td><td>";             echo $row['column2'];          echo "</td>";      }  } else {      echo "error.";  }      echo "</table>";    mysqli_close($conn);  ?>

what options clean output of utf-8 characters? tried several solutions found here , on other forums gave up. database collation utf8_unicode_ci

after $conn = mysqli_connect(..) add code

mysqli_query($conn, "set character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");  

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -