php - sanitizing a string before serializing and inserting to db -



php - sanitizing a string before serializing and inserting to db -

i'm facing odd problem....

$string user input

$log = serialize(array('string' => $string);

example: "test" be

"string";s:4:"test";

however problems arise when user submits quotes , other characters ; of course of study escape string first, serialized info cannot unserialized.

htmlentities before submitting db wouldn't work either since ; messes data...

any suggestions?

please don't tell me create db fields , not utilize serialize()

i not sure if best practice quick hack using : http://php.net/manual/en/function.base64-encode.php , http://www.php.net/manual/en/function.base64-decode.php encrypt info when sending db , decrypting when retrieve it. if think there might security issues encrypting using base64 here link in improve way : best way utilize php encrypt , decrypt?

php

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -