html entities get passed into database even when I use html_entity_decode
问题 $string = "susan's"; //string is scraped from website $string = html_entity_decode($string); $sql = 'INSERT INTO database SET name = "'. $string .'"'; When I echo out $sql, it shows correct one: INSERT INTO database SET name="susan's" , but when I run query it inserts susan's into database. When I run query manually from phpmyadmin it inserts correct one. Why do html entities get passed to database even when I remove them? 回答1: You need to use the ENT_QUOTES flag constant. As per the manual: