如何使用PHP和MYSQL将mysql数据库中的垃圾字符与阿拉伯字母匹配
我的问题简述如下:
该网站是用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题应该在早期阶段得到解决。阿拉伯字符不适合非 unicode 数据库表。这才是真正的问题。
您应该使用 Unicode 表以及与 MySQL 数据库的 Unicode 连接。
将表的默认字符集设置为 utf8 并确保与数据库的连接也使用此字符集:
另请参阅:https://www.php.net/manual/en/function.mysql-set-charset.php
检查当前连接的字符集:
另请参阅: https://www.php.net/ Manual/en/function.mysql-client-encoding.php
创建表时,请执行以下操作:
如果您已完成这些操作并将包含阿拉伯字符的用户添加到表中,您将看到它显示正确的。现在比较就很容易了。
祝你好运!
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:
See also: https://www.php.net/manual/en/function.mysql-set-charset.php
Check the character set of your current connection with:
See also: https://www.php.net/manual/en/function.mysql-client-encoding.php
When creating your tables do something like this:
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!
我有同样的问题,但我解决了。
您也可以包含下面的 php 代码:
mysql_set_charset("UTF8", $conn);
$conn
是我们的 mysql 连接。您可能还需要在网页中包含元标记:
希望对
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:
hope that helps
Sardar Jaf