Entering Exact Values into a Table Using SQL
Just do not use string interpolation or concatenation to get values into SQL queries in PHP. That's error prone and might make your program vulnerable to SQL injection attacks.
Use parameterized queries. See &quot;How to include a PHP variable inside a MySQL statement&quot; and &quot;How can I prevent SQL injection in PHP?&quot;.
Using parameterized queries will also ensure that the data is automatically escaped in the necessary way. So this also solves your problem. No manual escaping is necessary.