im making a comment system in my website. However, the commentor can break the system by typing special characters such as quotes, double quotes, semi-colons,colons etc. This is not a duplicate, i want to make sure that htmlentities are converted before it get to the database, i could use str_replace but it actually prints the literal code. for example: "
like this example:
$str ="Hi there bro what's up, im a "MEGA"";
$comment = $str;
echo $comment;
however it spits out errors, because they break the query because of the quotation marks.