|
照著14.6.2的範例但結果出現 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\update.php on line 20 似乎是在 $sql_db = "SELECT * FROM `students` WHERE `cID`=".$_GET["id"]; 這裡出了問題.... 請問該如何解決呢
原始碼如下 <?php include("3.php"); if (!@mysql_select_db("class")) die("資料庫選擇失敗!"); if(isset($_POST["action"])&&($_POST["action"]=="update")){ $sql_query = "UPDATE `students` SET "; $sql_query .= "`cName`='".$_POST["cName"]."',"; $sql_query .= "`cSex`='".$_POST["cSex"]."',"; $sql_query .= "`cBirthday`='".$_POST["cBirthday"]."',"; $sql_query .= "`cEmail`='".$_POST["cEmail"]."',"; $sql_query .= "`cPhone`='".$_POST["cPhone"]."',"; $sql_query .= "`cAddr`='".$_POST["cAddr"]."',"; $sql_query .= "`cHeight`='".$_POST["cHeight"]."',"; $sql_query .= "`cWeight`='".$_POST["cWeight"]."' "; $sql_query .= "where `cID`=".$_POST["cID"]; mysql_query($sql_query); header("Location: 3.php"); } $sql_db = "SELECT * FROM `students` WHERE `cID`=".$_GET["id"]; $result = mysql_query($sql_db); $row_result = mysql_fetch_assoc($result); ?> |