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 7721073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:49:55+00:00 2026-06-01T03:49:55+00:00

I have two tables- users and language with a foreign key link of their

  • 0

I have two tables- users and language with a foreign key link of their primary key ‘id’.
I have checked that the type is innoDB for the tables. I have delete- restrict and update -cascade.

This insert query, inserts it into the language table: (it can be more than one row which is added as the form has dynamic clickevent button)

if(empty($_SESSION['user_id'])) { // user not logged in; redirect to somewhere else }

$sql_insert = "INSERT into `language`
 (`native`,`other`,`other_list`,`other_read`, `other_spokint`
 ,`other_spokprod`,`other_writ`  )
VALUES
 ('$native','$other','$other_list','$other_read','$other_spokint','$other_spokprod',
 '$other_writ') ";

mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());     
}

This is the full error:

Insertion Failed:Cannot add or update a child row: a foreign key constraint fails
(`members`.`language`, CONSTRAINT `language_ibfk_1` FOREIGN KEY (`id`) 
REFERENCES `users` (`id`))

Any help would be appreciated!

Table structure for table language:

CREATE TABLE IF NOT EXISTS `language` (
 `id` bigint(20) NOT NULL AUTO_INCREMENT,
 `native` varchar(30) NOT NULL,
 `other` varchar(30) NOT NULL,
 `other_list` varchar(9) NOT NULL,
 `other_read` varchar(9) NOT NULL,
 `other_spokint` varchar(9) NOT NULL,
 `other_spokprod` varchar(9) NOT NULL,
 `other_writ` varchar(9) NOT NULL,
  PRIMARY KEY (`id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;


RELATIONS FOR TABLE `language`:
`id`
`users` -> `id`
  • 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-06-01T03:49:57+00:00Added an answer on June 1, 2026 at 3:49 am

    You have to use a structure like this:

    create table users (
        id int not null auto_increment,
        <additional fields>,
    
        primary key (id)
    ) ENGINE=InnoDB;
    
    
    create table language(
        id int not null auto_increment,
        user_id int not null,
        <additional fields>,
    
        primary key (id),
        foreign key (user_id) references users(id) on delete restrict on update cascade
    ) ENGINE=InnoDB;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: sites has_many users users belongs_to sites Is it better that
Below I have two tables users and users_profiles Both are innoDB and collation: utf8_general_ci
I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
I am using EF4 with the EDM designer. I have two tables : Users
If I have two tables - Logins and Users, as follows: Logins LoginIdNo UserIdNo
We have two tables - Tasks and TasksUsers (users assigned to task). Task has
I have two tables like this: Table Name: users emx | userid --------------- 1
I have Two tables. 1.Users table (Username , Name) 2.Picture table( ID , Username
I have two tables, users and hra. A user can only have one record

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.