0
"Obs: when the string has no simple quotes, it works perfectly, my problem is when it has simple quotes"
example with single quotes:
$name = "Michael";
$store = "Mike's Store";
"INSERT INTO database(name, store) VALUES('$name', '$store')";
with this, a syntax error happens, because the VALUES are actually passing like this:
"INSERT INTO database(name, store) VALUES('Michael', 'Mike's Store')";
like the string #store
has a simple quotes, this gives conflict with the other simple quotes, happening error:
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 happens:
"INSERT INTO database(`name`, `store`) VALUES('Michael', 'Mike's Store')";
I have tried to use backstricks instead of single quotes, in VALUES:
"INSERT INTO database(name, store) VALUES(`$name`, `$store`)";
but this error happens in Mysql(I believe in all columns):
Unknown column 'mike' in 'field list'
and that’s it...
in DB, there is some way to store a string that contains single quotes?
Man, thank you so much, solved the problem.
– Vinícius Alves