Search code examples
phpmysqlapostrophe

Best Practice WIth Apostrophe in Php Mysql Queries


Apostrophes can be a pain while sending sql update queries in from php when there's a non-matching "'" inside the string. What is the best practice to overcome this problem?

Thanks


Solution

  • I think the best practice is to use prepared statements, but you can use the addslashes($string) and stripslashes($string) functions too.