我正在尝试运行一个PHP页面,该页面应该在我的MSSQL表“users”中插入用户名和密码。当我运行页面时,唯一出现的是错误:
Warning: mssql_query() [function.mssql-query]: message: 'md5' is not a recognized built-in function name. (severity 15) in D:\Hostins0\html\insertadminaccount.php on line 10
Warning: mssql_query() [function.mssql-query]: Query failed in D:\Hostinstml\insertadminaccount.php on line 10
'md5' is not a recognized built-in function name.
这是我的完整PHP页面代码:
<?php
$conn=mssql_connect('sm','Gaer','Ra1!');
mssql_select_db('Gser',$conn);
if(! $conn )
{
die('Could not connect: ' . mssql_get_last_message());
}
$sqla = "INSERT INTO users (username, password)
VALUES ('rob_dewar01', " . md5 ('KingDozer') . ")";
mssql_query($sqla, $conn) or die(mssql_get_last_message());
if (!mssql_query) {
// The query has failed, print a nice error message
// using mssql_get_last_message()
die('MSSQL error: ' . mssql_get_last_message());
}
mssql_close($conn);
?>
感谢您的帮助。感谢所有帮助。
答案 0 :(得分:3)
MSSQL没有直接md5
功能(您可以将其转换为演示here)。您需要通过PHP使用它,如下所示:
$sqla = "INSERT INTO users (username, password)
VALUES ('rob_dewar01', '" . md5('KingDozer') . "')";
此外,md5
is not secure.请查看使用预准备语句。
有关PHP中哈希密码的更多信息,请参阅Secure hash and salt for PHP passwords问题。