Forum Moderators: coopster
<?php
include("config.php");$password = "randomstring12345";
$name = "fred";
$email = "fred@example.com";mysql_query("INSERT INTO test (name, email) VALUES (AES_ENCRYPT('$name', '$password'), AES_ENCRYPT('$email', '$password'))");
$query = mysql_query("SELECT id, AES_DECRYPT('name', '$password') as name, AES_DECRYPT('email', '$password') as email FROM test");
while($r = mysql_fetch_array($query)) {
echo $r['id'] . "-" . $r['name'] . "-" . $r['email'] . "<br>";
}
?>
This is inserting fine, but giving me NULL values for the encrypted records in the loop. What am I doing wrong?
*edit: both name and email are blob type in mysql
[edited by: FiRe at 4:59 pm (utc) on Jan. 19, 2008]
[edited by: dreamcatcher at 8:13 pm (utc) on Jan. 19, 2008]
[edit reason] Use example.com, thanks. [/edit]
[edited by: FiRe at 2:47 pm (utc) on Jan. 20, 2008]