The MySQL documentation says that it should be \\\'
. However, both scite and mysql shows that \'\'
works. I saw that and it works. What should I d
Possibly off-topic, but maybe you came here looking for a way to sanitise text input from an HTML form, so that when a user inputs the apostrophe character, it doesn't throw an error when you try to write the text to a SQL-based table in a DB. There are a couple of ways to do this, and you might want to read about SQL injection too, but a simple option in PHP is to use the htmlspecialchars() function which will convert all your apostrophes into '
which is possibly what you want to store anyway.
In PHP I like using mysqli_real_escape_string() which escapes special characters in a string for use in an SQL statement.
see https://www.php.net/manual/en/mysqli.real-escape-string.php
Replace the string
value = value.replace(/'/g, "\\'");
where value is your string which is going to store in your Database.
Further,
NPM package for this, you can have look into it
https://www.npmjs.com/package/mysql-apostrophe
There are three ways I am aware of. The first not being the prettiest and the second being the common way in most programming languages:
'I mustn''t sin!'
\
before the single quote'
: 'I mustn\'t sin!'
"I mustn't sin!"