So basically I’ve been digging deep into the realm of MySQL and PHP…specifically the security measures I should take when dealing with a database and form inputs. So far I’
You don't need to escape dollar sign. MySQL doesn't treat that character specially, and PHP only recognizes it in source code, not in string values (unless you call eval
on the string, but that's a whole other can of worms).
You would only need to escape %
and _
if you used user input as the argument to LIKE
and you didn't want the user to be able to use wildcards. This could come up if you're processing a search form. You don't need to use it when storing into the database.
You don't need to use htmlspecialchars
when accessing the database. That should only be used when you're displaying data to the user in an HTML page, to prevent XSS injection.