How to INSERT string with single quote ' symbol [duplicate]
问题 This question already has answers here : How can I prevent SQL injection in PHP? (28 answers) Closed 4 years ago . I want to do an INSERT into a MySQL database using: $sql = "INSERT INTO table (title1) VALUES ('$myVar')"; but the problem is $myVar can contain the single quotes ( ' symbols, e.g. in "idiot's"). Can somebody tell me how to handle any single quotes in the variable as a letter and not as a piece of code? (I know there are posts about this in the forum already, but I do not really