0 votes
in PHP by
How can I prevent SQL injection in PHP?

1 Answer

0 votes
by

Use PDO and prepared queries.

($conn is a PDO object)

$stmt = $conn->prepare("INSERT INTO tbl VALUES(:id, :name)");
$stmt->bindValue(':id', $id);
$stmt->bindValue(':name', $name);
$stmt->execute();

Related questions

0 votes
asked Jun 22, 2019 in PHP by SakshiSharma
0 votes
asked Jun 27, 2020 in PHP by DavidAnderson
...