ขึ้น warning:dir(cannot add or update a child row: a foreign key constraint fails) มันเกิดจากอะไรคะ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ขึ้น warning:dir(cannot add or update a child row: a foreign key constraint fails) มันเกิดจากอะไรคะ

ขึ้น warning:dir(cannot add or update a child row: a foreign key constraint fails) มันเกิดจากอะไรคะ
Warning: dir(Cannot add or update a child row: a foreign key constraint fails (`japanese_food`.`customer`, CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`District_ID`) REFERENCES `district` (`District_ID`)),Cannot add or update a child row: a foreign key constraint fails (`japanese_food`.`customer`, CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`District_ID`) REFERENCES `district` (`District_ID`))): The filename, directory name, or volume label syntax is incorrect. (code: 123) in C:xampphtdocsjapanese_foodcustomersave_register_customer.php on line 42


Oarthai 14.207.169.xxx 10-02-2015 20:27:05

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
เหมืนอค่าของ FOREIGN KEY ไม่มี ทำให้ไม่สามมารถอัพเดทข้อมูลได้
ลองเช็คว่าฟิลด์ที่สัมพันธ์กันมีค่าจริงหรือไม่


ninenik 124.122.128.xxx 11-02-2015
 ความคิดเห็นที่ 2
ขอบคุณค่ะ เดี๋ยวลองเช็คดูก่อน 


oarthai 14.207.169.xxx 11-02-2015 20:49
 ความคิดเห็นที่ 3
ลองพยายามทำแล้วค่ะ ไม่รู้จริงๆว่าต้องแก้ตรงไหน เช็คค่าแล้วสัมพันธ์กันนะค่ะ

<td><font size="2">&nbsp;&nbsp;&nbsp;เขต :</td>
          <td><select name="District">
 <option value="0">เลือกเขต</option>
   <?php
   $sql = "SELECT * FROM District ";
   $query = mysql_query($sql);
   while($result = mysql_fetch_array( $query)){
echo '<option value="'.$result["District_ID"].'">'.$result["District_Name"].'</option>';
 }
 ?>
</select></td>
 
 
-----------------------------------------------------------------------------------------
 
$sql = "INSERT INTO customer(Cus_FName,Cus_LName,Username,Password,Birthday,Sex,Age,
       Tel,House_No,Alley,Road,VALUES  
       ('".$_POST["FName"]."','".$_POST["LName"]."','".$_POST["Username"]."',
        '".$_POST["Password"]."','".$Birthday."','".$_POST["Sex"]."',
        '".$_POST["Age"]."','".$_POST["Tel"]."','".$_POST["House_No"]."',
        '".$_POST["Alley"]."','".$_POST["Road"]."','".$_POST["Sub_District"]."',
        '".$_POST["Province"]."','".$_POST["Post_Code"]."','".$_POST["Guidance"]."',
        '".$_POST["District_ID"]."')";
$query = mysql_query($sql);
mysql_query($sql) or die (mysql_error());
 
------------------------------------------------------------------------------------------
 
ขึ้น 
Cannot add or update a child row: a foreign key constraint fails (`japanese_food`.`customer`, CONSTRAINT `customer_ibfk_1` FOREIGN KEY (`District_ID`) REFERENCES `district` (`District_ID`))  
 


oarthai 14.207.201.xxx 15-02-2015 05:42
 ความคิดเห็นที่ 4
ได้แล้วค่ะ  ผิดเอง ใส่ค่าไม่ตรง หาเป็นวัน ผิดนิดเดียวจริงๆ 



oarthai 14.207.201.xxx 15-02-2015 17:55
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ