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

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

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