:4. _______ is an attack to inject code, in which malicious SQL code is passed to an instance of SQL Server from ______. 1.SQL injection, user input field 2.code injection, another server 3.both 1 and 2 4.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