php - 使用 PHP 强制 MySQL 字段小写

标签 php mysql uppercase lowercase

我有一个带有电子邮件字段的数据库,它循环遍历数据库以获取与某个电子邮件地址有关的所有交易。

当他们的电子邮件以几个大写形式存储时,用户输入小写字母会导致它不显示他们的交易。当我修改它以与其他电子邮件完美匹配时,它就起作用了。

我如何修改它,以便它可以正确地与电子邮件字段进行比较并且不区分大小写?是否会改变电子邮件的存储方式?

$result = mysql_query("SELECT * FROM `example_orders` WHERE `buyer_email`='$useremail';") or die(mysql_error());

提前致谢!

最佳答案

呃...您知道电子邮件地址是区分大小写的,,对吗?来自 RFC 2821 :

Verbs and argument values (e.g., "TO:" or "to:" in the RCPT command
and extension name keywords) are not case sensitive, with the sole
exception in this specification of a mailbox local-part (SMTP
Extensions may explicitly specify case-sensitive elements). That is, a command verb, an argument value other than a mailbox local-part,
and free form text MAY be encoded in upper case, lower case, or any
mixture of upper and lower case with no impact on its meaning. This
is NOT true of a mailbox local-part. The local-part of a mailbox
MUST BE treated as case sensitive.
Therefore, SMTP implementations
MUST take care to preserve the case of mailbox local-parts. Mailbox
domains are not case sensitive. In particular, for some hosts the
user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes interoperability
and is discouraged.

(强调)

关于php - 使用 PHP 强制 MySQL 字段小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10019594/

相关文章:

java - 如何在使用 String replaceAll 时跳过大小写

php - PHP 中的个人资料图片保存选项

javascript - jquery .更改多个文本框并选择从行到行检索数据

javascript - 避免影响加载列表

php - Mysql数组没有找到结果

php - 根据数据库中的表检查 url

MySQL 触发器 "syntax error, unexpected END, expecting ' ;'"

php - 如何重写这个 php filterArray 函数以获得更好的性能

java - 以全大写形式声明记录器并将其定为最终版本有什么区别吗?

C将文本文件中以小写字母开头的单词更改为大写字母