首頁  >  文章  >  資料庫  >  為什麼我在 MySQL 資料庫中看到問號而不是希伯來字元?

為什麼我在 MySQL 資料庫中看到問號而不是希伯來字元?

Susan Sarandon
Susan Sarandon原創
2024-11-14 11:11:01793瀏覽

Why Do I See Question Marks Instead of Hebrew Characters in My  MySQL Database?

Query Marks vs. Hebrew Characters in MySQL Database

When developing a shopping cart using PHP and MySQL, ensuring proper display of Hebrew characters is crucial. This issue arises when you encounter question marks instead of desired Hebrew characters. The solution to this problem involves optimizing database settings, PHP connection script, and HTML elements.

To resolve this issue, follow these steps:

Database Modifications:

  • Set the collation of the database to 'utf8_general_ci'.
  • Set the collation of the table containing Hebrew characters to 'utf8_general_ci'.

PHP Connection Script:

  • Add the following header to set the character encoding:

    header('Content-Type: text/html; charset=utf-8');
  • After connecting to the database, execute the following query to set the character set to UTF-8:

    mysql_query("SET NAMES 'utf8'");

HTML Script:

  • Include the following meta tag in the section of your HTML document:

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

By implementing these steps, you can ensure that Hebrew characters are displayed correctly in your MySQL database and web application.

以上是為什麼我在 MySQL 資料庫中看到問號而不是希伯來字元?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn