Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:06:31+00:00 2026-05-27T18:06:31+00:00

In phpMyAdmin when i try to add foreign key some error occurs and does

  • 0

In phpMyAdmin when i try to add foreign key some error occurs and does not tell what is wrong. Just says “FK fails”.

Can any one tell what is the problem?

Error

SQL query:

ALTER TABLE `hotel` ADD FOREIGN KEY ( `type_id` ) REFERENCES `hotel`.`hotel_type` (
`id`
) ON DELETE CASCADE ON UPDATE CASCADE ;

MySQL said: Documentation
#1452 - Cannot add or update a child row: a foreign key constraint fails (`hotel`.`#sql-cfc_e`, CONSTRAINT `#sql-cfc_e_ibfk_2` FOREIGN KEY (`type_id`) REFERENCES `hotel_type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:06:31+00:00Added an answer on May 27, 2026 at 6:06 pm

    Be sure the columns of both tables are of the same data-type:

    hotel.hotel type_id int(11) unsigned # type_id column of hotel table
    
    hotel.hotel_type id int(11) unsigned # id column of hotel_type table
    

    If they are not of the same type then you won’t be able to add your FK constraint.

    — Edit —

    Based on your response, the columns are the same data-types, so that means you have an invalid value in the hotels.type_id column (value doesn’t exist in the hotel_types table). Check the values in your hotels.type_id column and make sure they exist in your hotel_types.id column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PhpMyAdmin to add indexes on the tables but whenever i try
For some reason i keep getting the following error when i try to set
PHPMYAdmin gives me an error each time I try to export. Here's the error:
I get this error everytime I try to access phpmyadmin. http://i49.tinypic.com/ot1478.jpg I cant access
Whenever I try to connect to MySQL to access phpmyadmin, it returns an error:
I have just installed phpMyAdmin on my new Fedora Core 10 dedicated server. I
It's very strange because phpmyadmin is not in document root, but still can visit
I try this in PHPMyadmin: Update wp_1_posts SET post_content='<strong>Hello </strong> <a href=http://stackoverflow.com>stackoverflow</a> you think
I try to connect mysql via PHPMYADMIN, using my password, but it can't stop
I installed everything separately (Apache, PHP, MySQL and phpMyAdmin) and do not use a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.