0

This is a question in relation to the following response to an Encryption / Decryption question:

https://stackoverflow.com/a/5093422/2691346

I love this class, but I'm having trouble storing and retrieving the encrypted data on my database.

As the encrypted data contains all sorts of apparently unpredictable characters / codes, I'm using this:

$value = addslashes($e->encrypt($value, $randomnumber));

It's definitely generating an encrypted value, but when I try to update my database with it, it's not storing the entire value.

I've tried both text and blob column types, but neither appear to be correct.

Would mysql_real_escape_string be better than addslashes?

Am I using the correct column type?

Please can someone show me where I'm going wrong?

Many thanks!

Community
  • 1
  • 1
Mark
  • 163
  • 2
  • 9
  • Yes, `mysql_real_escape_string` is the proper function when using the mysql extension. Even better would be to use mysqli or PDO and use parametrized queries. – Barmar Jan 18 '14 at 07:27
  • Thanks! That did the trick. (I would use MySQLi, but I'm working with a script that still uses the older MySQL commands, so upgrading it is a job on my To Do list.) – Mark Jan 21 '14 at 03:58

0 Answers0