-1
我在代碼中收到解析錯誤。解析錯誤:語法錯誤,意外的T_ENCAPSED_AND_WHITESPACE,期待T_STRING或T_VARIABLE或T_NUM_STRING
我的代碼是:
$query="INSERT into tbl_result('result_uname','result_date','result_subject','result_rightans','result_wrongans','result_marks') values ('$uname','$curdate','$subject','10','10','$_SESSION['marks']')";
if(mysql_query($query))
{
header("Location: result.php");
?>
<script>alert("Your Answers Submitted...");</script>
<?php
}
else
{
?>
<script>alert('Error While Submitting...');</script>
<?php
}
**警告**:如果您剛剛學習PHP,請勿使用[ 'mysql_query'](http://php.net/manual/en/function.mysql-query.php)界面。這是非常可怕和危險的,它在PHP 7中被刪除了。[PDO的替代品並不難學](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps -pdo-for-database-access /)以及[PHP The Right Way](http://www.phptherightway.com/)等指南介紹了最佳實踐。你的用戶參數是**不是** [正確轉義](http://bobby-tables.com/php),並且有[SQL注入漏洞](http://bobby-tables.com/)可以被利用。 – tadman