我收到以下代碼中的以下錯誤。MySQL語法:您的SQL語法中有錯誤...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@doe.com,username,5f4dcc3b5aa765d61d8327deb882cf99,09/05/2011 1:11:13 AM)' at line 1
$username = $_GET['username'];
$password = md5($_GET['password']);
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$email = $_GET['email'];
$date = uk_date();
$conn = mysql_connect('localhost', 'myuser', 'mypass');
mysql_select_db('dbname');
$query = "INSERT INTO accounts (FirstName, LastName, Email, Username, Password, LastLoginDate) VALUES (". $firstname . ",". $lastname ."," . $email . "," . $username . "," . $password . "," . $date . ")";
$result = mysql_query($query) or die(mysql_error());
echo 'Success';
mysql_close($result);
能不能請您讓我知道,我的問題是什麼?我是MySQL和PHP的新手,所以請你提供一個解釋,說明我做錯了什麼,以備日後參考。
問題是,你是(等等等等等等等等等等等等等等),而且你沒有使用準備好的語句。 – BoltClock 2011-05-09 00:17:04
準備好的陳述是什麼意思? – 2011-05-09 00:18:16
看看[PHP PDO手冊]中的這篇文章(http://php.net/manual/en/pdo.prepared-statements.php)。準備好的語句對於幫助防範大多數Web應用程序易受攻擊的SQL注入攻擊都是不可或缺的。 – BoltClock 2011-05-09 00:18:54