"When the string has no single quotation marks, this works fine, my problem is when there are single quotation marks"
example with single quotes:
$name = "Michael";
$store = "Mike's Store";
"INSERT INTO database(name, store) VALUES('$name', '$store')";
With this, a syntax error occurs, because VALUES is actually going like this:
"INSERT INTO database(name, store) VALUES('Michael', 'Mike's Store')";
As the string #store
has a single quotation mark, this conflicts with the other single quotation marks, error occurring:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's Store' at line 1
I have tried to use backstricks in the column names and the same error occurs:
"INSERT INTO database('name', 'store') VALUES('Michael', 'Mike's Store')";
I have already tried to use backstricks in place of the single quotes in VALUES:
"INSERT INTO database(name, store) VALUES('$name', '$store')";
But this error occurs in MySQL (I believe in all columns):
Unknown column 'mike' in 'field list'
And that's it ...
In DB, is there any way to store a string that contains single quotation marks?