I have to insert some strings to my database.
The problem is that every time I use " ` " or " ' " it causes errors in the Sql.
For ex, when someone types "that's great" , it just messes everything up.
How can I solve this?
Thanks!
I have to insert some strings to my database.
The problem is that every time I use " ` " or " ' " it causes errors in the Sql.
For ex, when someone types "that's great" , it just messes everything up.
How can I solve this?
Thanks!
Use the real escape string function. Actually, MySQL prevents ' or ` from entering the system in order to prevent SQL Injection attacks.
Function Syntax: mysql_real_escape_string($your_string)
Use the mysqli escape string function:http://au1.php.net/manual/en/mysqli.real-escape-string.php (you shouldn't be using the mysql functions as they are depreciated) http://au1.php.net/manual/en/function.mysql-real-escape-string.php
Use a prepared/parameterized query.
Manual: http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php