<?php //The example selects and prints a specific row. $dsn = "mysql:host=localhost;dbname=mydb"; $user = "user12"; $passwd = "12user"; $pdo = new PDO($dsn, $user, $passwd); $id = 12; //This time we use named placeholder (:id) and bindParam. $stm = $pdo->prepare("SELECT * FROM countries WHERE id = :id"); $stm->bindParam(":id", $id, PDO::PARAM_INT); $stm->execute(); $row = $stm->fetch(PDO::FETCH_ASSOC); echo "Id: " . $row['id'] . PHP_EOL; echo "Name: " . $row['name'] . PHP_EOL; echo "Population: " . $row['population'] . PHP_EOL; ?>