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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:55:29+00:00 2026-05-27T23:55:29+00:00

I am currently trying to insert data into a table called customer_quote , this

  • 0

I am currently trying to insert data into a table called “customer_quote”, this table acts as a linking table between the “customer” table and the “customer_tariffs” table. It also records the user who sumbitted the data via the “user” table.

Here is a schema of my db:

https://i.stack.imgur.com/gyCdb.png
enter image description here

and here is a screenshot of the table that is not allowing me to insert into it.

https://i.stack.imgur.com/I7fsr.png

enter image description here

This is the process in how I insert into my db:

  1. Insert data into customer table
  2. Retrieve row id using mysql_insert_id
  3. Insert data into customer_quote <— Not working!

Here is the code:

    //code above this inserted data into customer table

//get id of row where data was just inserted
$sustomer->cid = mysql_insert_id($db);

//insert into customer_quote table
$database->query("INSERT INTO customer_quote (cid)
        Values ('$customer->cid')");

** New Error message**

‘Cannot add or update a child row: a foreign key constraint fails (quote_system.customer_quote, CONSTRAINT fk_customer_quote_customer FOREIGN KEY (cid) REFERENCES customer (id) ON DELETE NO ACTION ON UPDATE NO ACTION)’

As you can see that error feedback is useless , so after about three hours of testing I have concluded that the problem is my “cid” column in the “customer quote” table.

It only accepts certain values however my own php variable has the correct value which is available to insert via phpmyadmin as you can see in the screenshot below.

https://i.stack.imgur.com/jMS15.png

enter image description here

So it has to be the constraints or something else in my table that is stopping me?

Any ideas how to solve this.

Thanks!

  • 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-27T23:55:30+00:00Added an answer on May 27, 2026 at 11:55 pm

    I really hope its a simple typo in your question but your query isn’t correct :

    $database->query("INSERT INTO customer_quote (cid)
            Values ('$customer->cid'");
    

    should be

    $database->query("INSERT INTO customer_quote (cid)
            Values ('$customer->cid')"); // added closing bracket on values
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do bulk insert into a table: use SalesDWH go BULK
I received a MySQL data dump and am trying to insert the data into
I'm trying to insert information from a form into a database table and then
Currently looking to extract data from 2 tables and insert into another. Tables as
I am trying to insert data in table in mysql database through php code
I am trying to insert records into Access table from SQL Server table. For
I'm currently trying to get into the Java EE development with the Spring framework.
I'm currently trying to debug a customer's issue with an FTP upload feature in
I'm currently trying to pass a mono threaded program to multithread. This software do
I'm trying to insert values in the table but when I click on the

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.