Hosting Solutions
mobile_logo Table of Contents

PDO Prepared Statements PHP Tutorial

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; ?>

PHP Videos


Website Design Theme Application PHP Cookies CSS TutorialPDO Prepared Statements PHP TutorialPDO Tutorial Connect Database and Query ExampleActive Page Link Button Highlight TutorialGeoPlugin Tutorial Get User Location Information IP DetectionHashtag System and Regex PHP Programming TutorialPagination MySQLi Google Style Paged Results TutorialActive Clickable Link Function preg_replace Programming TutorialGet Favicon From Web Site Link Access External FilesRandom String Generator PHP Function Programming TutorialForce File Download Dialog In Browser TutorialCheck User Sign Up Name Ajax PHP Social Network TutorialFlat File Text Database System CMS Edit Content TutorialFlat File Text Database System Display ContentExperience Level Evaluation Programming TutorialStagger and Limit Dynamic Output in a While Loop Google AdsTwitter Dynamic Goodies Widget TutorialDynamic Google Maps Location TutorialPrepared Statements PHP mysqli Tutorial