Es sencillo usar PDO:
Código PHP:
Ver original<?php
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$nombre = $_GET['nombre'];
$sth = $dbh->prepare('SELECT * FROM personas WHERE name = ?');
$sth->execute(array($nombre)); foreach ($sth->fetchAll() as $row) {
}