我有一個mySQL查詢,當我運行一個包含'@'的字符串時卡住了。我試過htmlentities()和htmlspecialchars()無濟於事。以下是我正在運行的是什麼:從'@'開始的SQL語法錯誤
$name=$_POST['name'];
$first=$_POST['first'];
$last=$_POST['last'];
$bio=htmlentities($_POST['bio']);
$email=htmlentities($_POST['email']);
$pass=$_POST['pass'];
$date=date("m/d/y");
$bd=date('m-d-y',strtotime($_POST['month'].$_POST['date'].$_POST['year']));
$qer="insert into everything (user,first,last,bio,email,pass,date,bd) values ($name,$first,$last,$bio,$email,$pass,$date,$bd)";
if(!(mysql_query($qer,$con))){
echo "no qer";
echo mysql_error();
}
以下是錯誤:
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 '@re5yhgr5tyhrtyhr5tyr5tyhrt,[email protected],pass,12/13/12,01-01-70)' at line 1
我是第一次嘗試,它只是在我的電子郵件參數,但現在我知道它有麻煩,無論它在哪裏。 >:|
我假設「1號線」是SQL的第一行是因爲我的實際線路1「」 ......提前
很抱歉,如果這是顯而易見的,謝謝!
我喜歡那個表名, 「一切」 – kennypu
**請閱讀:** http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-function-in-php –