简体   繁体   中英

MYSQL UPDATE in PHP using AES_ENCRYPT

I am trying to do a basic mysql update using AES_ENCRYPT in PHP but I cant get it work. Here is my full code:

$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 error log is fine, there is no error. Only this:

Query Failed 
UPDATE parent SET Column1 = AES_ENCRYPT('722225374673255299521908919676768...etc','bac09c63f34c9845c707228b20cac5e0')

使用此查询-

UPDATE parent SET Column1 = AES_ENCRYPT('$Column1','$key'), Column2 = AES_ENCRYPT('$Column2','$key') WHERE Parent_ID = $id;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM