r/backtickbot • u/backtickbot • Apr 19 '21
https://np.reddit.com/r/PHPhelp/comments/mtuhqs/pdo_query_differences/gv29ivu/
Is open for SQL injection, throw it into trash
Uses prepared statements with positional parameters
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