From 1f5cdbb3780830587472b3b7efcfaabe30c06999 Mon Sep 17 00:00:00 2001 From: eliasnicolas07 Date: Wed, 26 Aug 2015 04:20:58 -0300 Subject: [PATCH] Update to include PDO I have updated to include PDO instead of deprecated mysql_* --- examples/php-example.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/php-example.php b/examples/php-example.php index 381359f6..20d36b49 100644 --- a/examples/php-example.php +++ b/examples/php-example.php @@ -1,4 +1,4 @@ -getMessage(); +} # Perform the query -$query = sprintf("SELECT id, name from mytable WHERE name LIKE '%%%s%%' ORDER BY popularity DESC LIMIT 10", mysql_real_escape_string($_GET["q"])); +$query = sprintf("SELECT id, name from mytable WHERE name LIKE '%%%s%%' ORDER BY popularity DESC LIMIT 10", +mysql_real_escape_string($_GET["q"])); + +$stmt = $dbh->prepare("SELECT id, name from mytable WHERE name LIKE ? ORDER BY popularity DESC LIMIT 10"); +$stmt->bindValue(1,'%%%'.htmlspecialchars($_GET["q"]).'%%%'); +$stmt->execute(); $arr = array(); -$rs = mysql_query($query); # Collect the results -while($obj = mysql_fetch_object($rs)) { +while($obj = $stmt->stmt->fetch(PDO::FETCH_OBJ)) { $arr[] = $obj; }