Mysql PDO standard insert (persist) of data to a table with placeholders to protect from MySQL injection attacks

This is a much more secure way to insert records and prevent MySQL injection.  This assumes that $this-conn is your MySQLi PDO database connection object that you’ve already initialized:

Please note that a lot of the PHP snippets on this site assume you have some level of PHP experience.  I use this site as a repository of many frequent code snippets and things I find I look up a lot as a central way to reference materials.  Feel free to use and share as you see fit!

- Aaron Belchamber


Leave a Reply

Your email address will not be published. Required fields are marked *