Special characters in PHP / MySQL

Quick and easy fix for when you code displays weird characters ??? instead of displaying the right characters:


<?php
mysqli_query($conn, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
?>

I place this right after my database connection to make sure every character is displayed correctly.

I also place this code on every html page:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar