Reputation: 734
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!
Upvotes: 0
Views: 2225
Reputation: 626
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)
Upvotes: 2
Reputation: 13972
Use a prepared/parameterized query.
Manual: http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php
Upvotes: 1
Reputation:
Use the mysqli escape string function:https://www.php.net/manual/en/mysqli.real-escape-string.php (you shouldn't be using the mysql functions as they are depreciated) https://www.php.net/manual/en/function.mysql-real-escape-string.php
Upvotes: 1