Insert Text Input Value into MYSQL DB when string contains '

I am trying to insert a row into the DB on button press

INSERT INTO table
VALUES(
{{ tbl.selectedRow.id}},
{{ description.value }}
)

I've simplified the query
The issue comes from inserting the description.value
The string "They've got no answer" will break because it contains '

The raw SQL statement to the DB is:
INSERT INTO table
VALUES(
'12345' ,
'They've got no answer'
)

What is the correct way to insert multiline strings from text areas into the DB when they contain quotes?

Hi Jake, have you tried doubling up the quotes in the text string? i.e. put another ' before the ' ?

If you want to do this automatically you can add .replace(/'/g, "''") to the end of your description field i.e. {{description.value.replace(/'/g, "''") }} this will automatically double up any single quote and should force My SQL to not interpret the single ' as the end of the string.

To echo @stu, you’ll need to escape single quotes in text strings by doubling them. Here's an example where I'm trying to insert the last name O'connor. By doubling the single quotes like 'O''Connor' I'm able to successfully insert the string. Hope that helps! Let me know if you have any questions.