r/backtickbot • • Apr 19 '21

https://np.reddit.com/r/PHPhelp/comments/mtuhqs/pdo_query_differences/gv29ivu/

  1. Is open for SQL injection, throw it into trash

  2. Uses prepared statements with positional parameters

  3. Uses prepared statements with named parameters, and the old array syntax

I'd do

$sql = "SELECT * FROM credentials WHERE userID != :userid section = :section ";
$stmt = $mysqli->prepare($sql);
$stmt->execute([
      ':userid' => $userID,
      ':section' => $section,
]);

and name the db object properly, $pdo, not $mysqli, to avoid confusion

1 Upvotes

0 comments sorted by