How would I go about inserting apostrophes ‘ into MySQL without it throwing any errors in PHP. What would be the proper way to echo them out from MySQL too.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to consider both PHP and MySQL, and if you are using a framework, that too.
As far as PHP is concerned, you need to use the opposite style of quote from those contained in your string, or else “escape” them, like this:
As for MySQL, you should use an escaping function, like mysql_real_escape_string or similar.
There is a more advanced technique for using user-supplied data in queries called “prepared statements”, which is the most robust and safe way to achieve dynamic queries with user-supplied parameters. See this section of the docs to get started.