$data = "INSERT into detail(id,event) VALUES (1,"quest '15")";
Im having trouble with the single quote '15
.i tried to use \'15
but doesnt seem to work.
$data = "INSERT into detail(id,event) VALUES (1,"quest '15")";
Im having trouble with the single quote '15
.i tried to use \'15
but doesnt seem to work.
The problem isn't the single quote; the problem is the use of double quotes within a string literal that is enclosed in double quotes. Your double quoted string literal is actually being ended right before quest
.
One alternative is to use single quotes for string literals within SQL text. Within a string literal, you'll need to "escape" the single quote, and one way to do that is by preceding a single quote by another single quote.
For example:
$data = "INSERT into detail(id,event) VALUES (1,'quest ''15')";
^ ^^ ^
If you do that, the value for the event
column will be seen as quest '15
I strongly suggest using prepared statements, but in lieu of that, you can use mysqli_real_escape_string.
$data "INSERT INTO detail (id, event) VALUES (1, '".mysqli_real_escape_string("quest '15")."')";