Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

PDO Prepared Statements PHP Tutorial

Published :
Author :
Adam Khoury
Learn to create PDO Prepared Statements and quickly discover its key benefits. In the very next video tutorial you can learn to create prepared statements using mysqli. Prepared statements work for Both the PDO and mysqli extensions in PHP. <?php $db = new PDO('mysql:host=localhost;dbname=db_name', 'db_user', 'db_password'); // :username, :gender, :country are named placeholders in the SQL syntax below $sql = "INSERT INTO people (username, gender, country) VALUES (:username, :gender, :country)"; $stmt = $db->prepare($sql); $stmt->bindParam(':username', $username); $stmt->bindParam(':gender', $gender); $stmt->bindParam(':country', $country); $username = 'Beth'; $gender = "f"; $country = "Canada"; $stmt->execute(); $username = 'Sandeep'; $gender = "m"; $country = "India"; $stmt->execute(); echo "Prepared statements have been executed"; $db = null; ?>