php - Escaping quotes before MySQL -
here have script validate description users pass:
if(strlen($_post['descriprtion']) >250) { //some error code here } else { $description = $mysqli->escape_string(htmlentities(trim($_post['description']))); } now, test description i'm testing. give me when print out page:

as can see, there's black slash before single quote.
i considering using stripslashes(), should use it?
use stripslashes() when want echo variable.
echo $var; // --> i\'m testing. not funny. echo stripslashes($var); // --> i'm testing. not funny.
Comments
Post a Comment