如何使用PHP和MYSQL将mysql数据库中的垃圾字符与阿拉伯字母匹配

发布于 2024-09-28 14:39:35 字数 204 浏览 4 评论 0原文

我的问题简述如下:

该网站是用PHP作为前端、mysql作为后端开发的。

我通过输入阿拉伯字母在我的网站上注册。并且该值也插入到mysql数据库中。但它不是我输入的格式。看起来像是垃圾词。

现在我的问题是,当我尝试登录时,我无法匹配我输入的输入。我被这个地方困住了。

任何想法或建议都会有帮助和感激。

提前致谢..

My question in brief here:

The site is developed with PHP as front end and mysql as backend.

I am registering in my site by entering the arabic letters. And the value also inserted in mysql database. But it is not in the format what i entered. It looks like junk words.

Now my problem is when i try to login i can't able to match the input what i entered. I am stuck with this place.

Any ideas or suggestion will be helpful and grateful.

thanks in advance..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小鸟爱天空丶 2024-10-05 14:39:35

这个问题应该在早期阶段得到解决。阿拉伯字符不适合非 unicode 数据库表。这才是真正的问题。

您应该使用 Unicode 表以及与 MySQL 数据库的 Unicode 连接。

将表的默认字符集设置为 utf8 并确保与数据库的连接也使用此字符集:

$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);

另请参阅:https://www.php.net/manual/en/function.mysql-set-charset.php

检查当前连接的字符集:

echo mysql_client_encoding($conn);

另请参阅: https://www.php.net/ Manual/en/function.mysql-client-encoding.php

创建表时,请执行以下操作:

create table user (
    // Your table definition
) default charset = UTF8

如果您已完成这些操作并将包含阿拉伯字符的用户添加到表中,您将看到它显示正确的。现在比较就很容易了。

祝你好运!

This problem should be solved in an earlier stage. Arabic character do not fit in a non-unicode databasetable. That's the real problem.

You should use Unicode tables as well as a Unicode connection to your MySQL database.

Set the default character set of your table to utf8 and make sure the connection to your database is also using this character set:

$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);

See also: https://www.php.net/manual/en/function.mysql-set-charset.php

Check the character set of your current connection with:

echo mysql_client_encoding($conn);

See also: https://www.php.net/manual/en/function.mysql-client-encoding.php

When creating your tables do something like this:

create table user (
    // Your table definition
) default charset = UTF8

If you have done these things and add a user which contains arabic character to your table, you will see it is displayed correct. Now the comparison will be easy.

Good luck!

请你别敷衍 2024-10-05 14:39:35

我有同样的问题,但我解决了。

您也可以包含下面的 php 代码:

mysql_set_charset("UTF8", $conn); $conn 是我们的 mysql 连接。
您可能还需要在网页中包含元标记:

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

希望对

Sardar Jaf有帮助

I had the same problem but I fixed it.

you can alternatively include a php code below:

mysql_set_charset("UTF8", $conn); $conn, is our mysql connection.
you may also need to include the meta tag in your web page:

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

hope that helps

Sardar Jaf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文