Hello,
I have a mysql field that is a blob and I use encode to encrypt the values for that field.

One of the values is: 62756d7069886d66

When I use the salt: ulabula

to decode it via phpmyadmin,

the correct value returns: 62756d7069886d66

However when I do the exact same query via my php script:

$query = "SELECT DECODE(thisfield, 'ulabula') FROM mytable LIMIT 1";
$result = mysql_query ($query);
$row = mysql_fetch_row($result);

And when I echo $row[0], I get this: bumpiˆmf

when I should get this: 62756d7069886d66

Any thoughts as to what I am doing wrong?

Maybe you are using another character encoding in php than in phpMyAdmin. Try to submit SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8' (substitute the actual character set value for 'utf8') before you send your query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.