When can SQL injection occur? 1 point It can occur when the user inputs a valid SQL statement that gets run on database. It can occur when the user inputs a valid keyword that gets run on database. All of the above None of the above code example

Example: sql injection attack

$value = "your value here";

try {
            $pdo = new PDO($dsn, $username, $password, $>drivers);
        } catch (\PDOException $e) {
            echo 'Connection Failed: ' . $e->getMessage();
        }
        
$sql = "INSERT INTO `my_db` SET `field` = ? ";
$stmt = $this->pdo->prepare($sql);
        $stmt->bindValue(1, $value, PDO::PARAM_STR);
        $stmt->execute();
        $stmt = null;

Tags:

Sql Example