0

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!

1

3 Answers 3

2

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)

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

Could you please help me upgrading my code to mysqli? lets get into a chat.
1

Use a prepared/parameterized query.

Manual: http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.