Okay, I need to know this (for my own education)...
Assuming my server automatically escapes POST quotes, and further, I use the following code to strip the slashes and replace quotes, shouldn't it produce a fully database-friendly string?
$before = $_POST['string'];
$after = htmlentities(stripslashes($before), ENT_QUOTES);
Here's the before(server-scrubbed) and after(code-scrubbed) of the output:
<!-- Injection attempt: "=* OR 1" -->
<!-- Same thing happens with: '=* OR 1' -->
Before string = \'=* OR 1\'
After string = & #039;=* OR 1& #039;
(Note: I had to add a space after the ampersand because the message composer kept converting it to a single-quote.)