我正在尝试使用PHP中的AES_ENCRYPT进行基本的mysql更新,但我无法让它工作。 这是我的完整代码:
$key = "bac09c63f34c9845c707228b20cac5e0";
$query = " SELECT id, aes_decrypt(Column1, '$key') AS Column1, aes_decrypt(Column2, '$key') AS Column2 FROM parent WHERE Request = '{$Request}' ORDER BY ID ASC;";
$resultSet = mysql_query($query, $DB);
while ($row = mysql_fetch_array($resultSet)) {
$id = $row['ID'];
$rows[] = $row["Request"];
$Column1 = $row["Column1"];
$Column2 = $row["Column2"];
$SQL = "UPDATE parent SET Column1 = AES_ENCRYPT('$Column1','$key'), Column2 = AES_ENCRYPT('$Column2','$key') WHERE Parent_ID = '$id';";
if (!mysql_query($SQL, $DB))
die("Query Failed $SQL");
}
PHP错误日志没问题,没有错误。只有这个:
Query Failed
UPDATE parent SET Column1 = AES_ENCRYPT('722225374673255299521908919676768...etc','bac09c63f34c9845c707228b20cac5e0')
答案 0 :(得分:1)
使用此查询 -
UPDATE parent SET Column1 = AES_ENCRYPT('$Column1','$key'), Column2 = AES_ENCRYPT('$Column2','$key') WHERE Parent_ID = $id;