I need to store a number encrypted in my postgres database. I wanted to use mcrypt with the 3DES function, the encrypting and decrypting is working fine, but I can't store it in the database. My database field is char(50).
$key = "this is a secret key";
$input = "123456789";
$test = mcrypt_ecb(MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT);
$db = pg_connect("host=localhost dbname=testdb user=haxo");
$sql = "insert into test (pin) values('".$test."')";
$result = pg_query($sql);
if (!$result) {
$errormessage = pg_last_error();
echo "Error with query: " . $errormessage;
exit();
}
pg_close();
The error I'm getting is: ERROR: unterminated quoted string at or near "'Ÿlä"