the encrypted result data maybe binary data which may cause errors in sql query.
Try using the base64_encode/base64_decode function with mcrypt()
e.g.
base64_encode(mcrypt_ecb(MCRYPT_BLOWFISH,$key,$input,MCRYPT_ENCRYPT));
mcrypt_ecb(MCRYPT_BLOWFISH,$key,base64_decode($input),MCRYPT_DECRYPT);
** the following was cribbed from php.net