I'm currently having some trouble getting a login system to work and I believe I have found the reason why, though I have no idea why it is happening or what specifically is causing it.
我目前在登录系统工作时遇到了一些麻烦,我相信我找到了原因,但我不知道为什么会这样,或者具体是什么导致它。
I have a hashed password stored in a database. The value of the password
column is:
我有一个存储在数据库中的哈希密码。密码列的值是:
18e2acd33fd3ec752c344b463d00238e35b6b77ed65941f69b9eb96471834f1e507d846071768548f8cf125d6c74ce614d477a576657983bb8620bbc49eed7de
Now when I go to simply select and print that field in PHP like so:
现在,我只需选择并在PHP中打印该字段,如下所示:
$query = "SELECT password FROM webusers WHERE username = 'Roy'";
$update = odbc_exec($connect, $query);
$row = odbc_fetch_array($update);
print $row['PASSWORD'];
It outputs:
它输出:
18e2acd33fd3ec752c344b463d00238e35b6b77ed65941f69b9eb96471834f1e507d846071768548f8cf125d6c74ce614d477a576657983bb8620bbc49eed7d
Scroll to the very end of both hashes and you'll see the second hash is missing a final 'e' and so this is throwing off my entire login system. Why would this be happening? I'm not sure whether PHP or SQL is to blame.
滚动到两个哈希的最后,你会看到第二个哈希缺少最后的'e',所以这就是抛弃我的整个登录系统。为什么会这样?我不确定是否应该责怪PHP或SQL。
I'm using PHP 5.4.7 and the database is a 4D SQL server connected via ODBC.
我使用的是PHP 5.4.7,数据库是通过ODBC连接的4D SQL服务器。
Edit: The datatype of password
is Text
which, according to 4D's manual, can hold up to 2GB of data so the column size is not the issue.
编辑:密码的数据类型是Text,根据4D的手册,它可以容纳最多2GB的数据,因此列大小不是问题。
1 个解决方案
#1
0
To determine whether your problem is in MySQL or PHP, log into MySQL directly and determine if you are able to retrieve the full value while executing the SQL command directly. I would use the same SQL query that PHP is using so that you see the same output from the MySQL system that your application will see. If you see a truncated value while you are in MySQL (PHP is no longer part of the picture), then you know, with certainty, that you have exceeded the character limitations of the field you have defined in MySQL. Similarly, if the string displays perfectly, then PHP must be truncating the value.
要确定您的问题是在MySQL还是PHP中,请直接登录MySQL并确定在直接执行SQL命令时是否能够检索完整值。我将使用与PHP相同的SQL查询,以便您可以看到应用程序将看到的MySQL系统的相同输出。如果你在MySQL中看到截断值(PHP不再是图片的一部分),那么你肯定知道你已经超出了你在MySQL中定义的字段的字符限制。同样,如果字符串显示完美,那么PHP必须截断该值。
If PHP is truncating the value, then it could be a limitation of the mysql_result object, or it could be a system limitation of PHP, which seems less likely. By narrowing down the location of the problem further, your answer will become clear.
如果PHP正在截断该值,那么它可能是mysql_result对象的限制,或者它可能是PHP的系统限制,这似乎不太可能。通过进一步缩小问题的位置,您的答案将变得清晰。
I have not seen PHP truncate a string, ever. I have stored at least one megabyte of data in a single string value while making attachment headers for e-mails. I do not believe that your limitation lies in the PHP native language.
我还没见过PHP截断字符串。我在为单个字符串值存储了至少一兆字节的数据,同时为电子邮件制作附件标题。我不相信你的限制在于PHP本地语言。
#1
0
To determine whether your problem is in MySQL or PHP, log into MySQL directly and determine if you are able to retrieve the full value while executing the SQL command directly. I would use the same SQL query that PHP is using so that you see the same output from the MySQL system that your application will see. If you see a truncated value while you are in MySQL (PHP is no longer part of the picture), then you know, with certainty, that you have exceeded the character limitations of the field you have defined in MySQL. Similarly, if the string displays perfectly, then PHP must be truncating the value.
要确定您的问题是在MySQL还是PHP中,请直接登录MySQL并确定在直接执行SQL命令时是否能够检索完整值。我将使用与PHP相同的SQL查询,以便您可以看到应用程序将看到的MySQL系统的相同输出。如果你在MySQL中看到截断值(PHP不再是图片的一部分),那么你肯定知道你已经超出了你在MySQL中定义的字段的字符限制。同样,如果字符串显示完美,那么PHP必须截断该值。
If PHP is truncating the value, then it could be a limitation of the mysql_result object, or it could be a system limitation of PHP, which seems less likely. By narrowing down the location of the problem further, your answer will become clear.
如果PHP正在截断该值,那么它可能是mysql_result对象的限制,或者它可能是PHP的系统限制,这似乎不太可能。通过进一步缩小问题的位置,您的答案将变得清晰。
I have not seen PHP truncate a string, ever. I have stored at least one megabyte of data in a single string value while making attachment headers for e-mails. I do not believe that your limitation lies in the PHP native language.
我还没见过PHP截断字符串。我在为单个字符串值存储了至少一兆字节的数据,同时为电子邮件制作附件标题。我不相信你的限制在于PHP本地语言。