經過長時間的搜尋沒有能夠找到解決SQL語法錯誤和取消定義索引錯誤
Undefined index: coursename in C:\wamp\www\StudentInformationProject\Student_new\courseinsert.php on line 17
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 '1'>
這裏之後是代碼
if(isset($_POST["button"]))
{
$sql="INSERT INTO course(courseid, coursename, comment, coursekey)
VALUES('".$_POST['courseid']."','".$_POST['coursename']."',
'".$_POST['comment']."','".$_POST['coursekey']."')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
else
{
echo "1 record Inserted Successfully...";
}
}
「未定義的索引:coursename」 - 您似乎沒有在發佈課程名稱。另外,我希望你能儘快學習SQL注入。 – Blorgbeard
嘗試''echo''sql'並查看是否可以看到它有什麼問題 – Blorgbeard
正如@Blorgbeard所說,檢查[this](http://stackoverflow.com/questions/60174/how-to-prevent-sql步噴射功能於PHP?RQ = 1) –