請幫助我,我嘗試插入數據庫與注入攻擊保護,我發現了一些w3schools的例子,但它不適用於我。連接是正確的,並工作。由於我是SQL和編程方面的新手,我不知道那個Insert有什麼問題。請,任何人都可以幫忙嗎?非常感謝。插入數據庫與注入攻擊保護
我插入PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<p>Connected successfully</p>";
$From = $_GET['From'];
$To = $_GET['To'];
$Type = $_GET['Type'];
$text = $_GET['text'];
$stmt = $conn->prepare("INSERT INTO orders (from_lang, to_lang, tex)
VALUES (:fr, :to, :tex)");
$stmt->bindParam(':fr', $From);
$stmt->bindParam(':to', $To);
$stmt->bindParam(':tex', $text);
$stmt->execute();
?>
將mysqli與PDO混合使用。 'bindParam'用於pdo,'bind_param'用於mysqli – Saty
[如果您打算使用PDO,請一路走下去。](http://jayblanchard.net/demystifying_php_pdo.html) –
我想用mysqli的。我將'bindParam'改爲'bind_param',它仍然不起作用。 –