derfelix
01-28-2010, 09:33 AM
Sorry if this question sounds stupid...
I am adapting an old hack of mine, for a multilanguage site.. (in utf8)
I have title, description and username to put into database (and pull from database and display)
In the very old version info was escaped with addslashes($title),addslashes($description),addsla shes($username)
and before display: stripspashes($title) etc.. etc...
I now would like to do it with :
$db->escape_string($title), $db->escape_string($description), $db->escape_string($username)
Thats ok.. and I dont need the stripslashes anymore..
BUT...
Should I add htmlspecialchars_uni before saving to db? OR after pulling from db?
I meen should i do when saving...
$db->escape_string(htmlspecialschars_uni($title)), $db->escape_string(htmlspecialschars_uni($description)) , $db->escape_string(htmlspecialschars_uni($username))
Or should i only add the htmlspecialschars_uni() only before display..
(not before saving but:
$title = htmlspecialschars_uni($title);
$description = htmlspecialschars_uni($description);
$username = htmlspecialschars_uni($username);
I hope you understand what i meen..
F.
I am adapting an old hack of mine, for a multilanguage site.. (in utf8)
I have title, description and username to put into database (and pull from database and display)
In the very old version info was escaped with addslashes($title),addslashes($description),addsla shes($username)
and before display: stripspashes($title) etc.. etc...
I now would like to do it with :
$db->escape_string($title), $db->escape_string($description), $db->escape_string($username)
Thats ok.. and I dont need the stripslashes anymore..
BUT...
Should I add htmlspecialchars_uni before saving to db? OR after pulling from db?
I meen should i do when saving...
$db->escape_string(htmlspecialschars_uni($title)), $db->escape_string(htmlspecialschars_uni($description)) , $db->escape_string(htmlspecialschars_uni($username))
Or should i only add the htmlspecialschars_uni() only before display..
(not before saving but:
$title = htmlspecialschars_uni($title);
$description = htmlspecialschars_uni($description);
$username = htmlspecialschars_uni($username);
I hope you understand what i meen..
F.