我使用PHP,MYSQL和JQuery創建兩級下拉選擇框。一切似乎都很好,但是當我的父類別沒有孩子或者我沒有選擇孩子時,它給了我錯誤,我無法理解這個錯誤意味着什麼以及如何解決。我需要你的幫助。MySQL聲明:未定義索引:如何解決
錯誤: Notice: Undefined index: f_child_cat in C:\xampp\htdocs\pathtofile\index.php on line 58 You selected 12 & 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 '' at line 1
這是我的前端代碼
<?php if(isset($_POST['submit'])){
$drop = $_POST['first_child_cat'];
$f_child_cat = $_POST['f_child_cat'];
echo "You selected ";
echo $drop." & ".$f_child_cat;
$query = mysql_query("SELECT * FROM qa_categories WHERE parentid = $f_child_cat")
or die(mysql_error());
echo '<ul>';
while($cats = mysql_fetch_array($query))
echo '<li>',$cats['title'],'</li>';
echo '</ul>';
}
?>
什麼錯誤,你在哪裏得到它? – Pete 2013-03-22 18:39:34
對不起,我剛剛更新了問題。你能再請檢查一次。謝謝 – 2013-03-22 18:40:17