Foreign Key Problems

Discussion in 'MySQL' started by shoapin, Feb 26, 2012.

  1. #1
    I need help with the foreign key, this is the php portion of my site to insert records, i am testing so i am only entering one. When i hit the creat account button it sends me to another page to insert additional info. I add info to the first page no problem but when i add to the 2nd page and submit i get the error: Cannot add or update a child row: a foreign key constraint fails (`search_info`.`properties`, CONSTRAINT `properties_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `information` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE). Can someone help please?
     
    Last edited: Feb 26, 2012
    shoapin, Feb 26, 2012 IP
  2. trendint

    trendint Peon

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Without knowing the rest of your setup; you probably are most likely entering a "customer_id" that does not coincide with an existing customer_id reference on the "information" table.
     
    trendint, Feb 28, 2012 IP
  3. Lavi

    Lavi Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    hello,check if you are entering the correct value of customer_id into the INFORMATION table. the value should be the same as you are trying to enter into the second table. Make sure it gets saved in the INFORMATION table.
     
    Lavi, Mar 17, 2012 IP