This is for mysqli_*, there are similar ones for mysql_* and PDO (see bottom of this answer).Īlso make sure your database and tables are set to UTF-8, you can do that like this: ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci ĪLTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci $conn->set_charset("utf8") /* Object-oriented approach */ Upon connecting to the database, set the charset to UTF-8 for your connection-object, like this (directly after connecting) mysqli_set_charset($conn, "utf8") /* Procedural approach */ PHP (at the top of your file, before any output): header('Content-Type: text/html charset=utf-8') The header in both PHP and HTML should be set to UTF-8 Save the document as UTF-8 w/o BOM (If you're using Notepad++, it's Format -> Convert to UTF-8 w/o BOM).ALL attributes throughout your application must be set to UTF-8.This covers most of the general problems one can face when developing a PHP/MySQL application. Here's a few pointers which can help you get the right charset for your application. Your actual issue is a charset problem somewhere. You should stick with mysqli_ (as it seems you are anyway), as mysql_* functions are deprecated, and removed entirely in PHP7. You are mixing APIs here, mysql_* and mysqli_* doesn't mix.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |