Hello, I'm using the PHP function FILE_GET_CONTENT in order to recieve the HTML code from some website. For some reason, when I tried to input the HTML code into the DB I got the follow message: Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use I check it and I find the apostrophe (') in the HTML code cause this error. When I tried to input the HTML code directly into the DB (using PHPMYADMIN) all worked fine. How can I fix it?
Thanks Stephan, I used: $html = addslashes(file_get_contents($url)); PHP: why did you wrote '.addslashes($htmlcode).' with apostrophe and dot ?
Nope Have a Look here http://www.w3schools.com/PHP/func_mysql_real_escape_string.asp You can Use this function to prevent database attack!
I don't use "" as php will take time to look through the string for variables. So instead I use '' to get a variable value into a string. examples $str = "Hello $name"; PHP: $str = 'Hello '.$name; PHP: That's how I do it but other ways are not wrong.