I'm trying to encode/decode some data, but I am apparently unable to decode it correctly.
One script uses some coding that can be simpliified like this:
mysql_query("UPDATE table SET data = ENCODE('the_data','a_password') WHERE something='something'");
Later, another script uses coding that can be simplified like this:
mysql_query("SELECT DECODE('the_data','a_password') AS data FROM table WHERE something='something'");
If I only ENCODE the data, and I don't DECODE it, my query returns a bunch of gibberish that is the same length as my original data (16 characters).
If I do DECODE the data, I get 9 characters of gibberish, but not the original 16 character data.
Any suggestions would be appreciated.
Mike Wilkinson
Encode / Decode Problem
Moderator: General Moderators
Correction
Sorry, my SELECT query should be like this:
mysql_query("SELECT DECODE('data','a_password') AS the_data FROM table WHERE something='something'");
Thanks in advance,
Mike Wilkinson
mysql_query("SELECT DECODE('data','a_password') AS the_data FROM table WHERE something='something'");
Thanks in advance,
Mike Wilkinson
Take out the quotes around data in the decode statement:
That way, it will use what's stored in the DATA column, rather than trying to decode the literal string "data".
Code: Select all
mysql_query("SELECT DECODE(data,'a_password') AS the_data FROM table WHERE something='something'");