Jump to content

A sql error message on my website, pls Im new to php and sql!


callisto11

Recommended Posts

 

Hi Everyone,

 

Im getting this sql error message on my website, which I dont understand, I know it has nothing to do with php. I was just hoping someone with php and sql experience will understand it and explain it more to me what I have done wrong.

 

Thank you ???

 

 

Error Message:

 

Cannot add or update a child row: a foreign key constraint fails (`rm_production/new_order`, CONSTRAINT `new_order_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`))

Link to comment
Share on other sites

To darkfreaks,

 

This is the code of what Im trying to do:

<?php

session_start();
require "connect.php";
$email = $_SESSION['email'];
$quantity = $_GET['quantity'];

$query = "insert into new_order values (0,'".$date_of_order."','".$date_paid."',0,'".$customer_id."')";
$result = mysql_query($query, $connection) or die (mysql_error ());

$order_id = mysql_insert_id($connection);

foreach($_SESSION['cart'] as $key => $cartoon)
{
$query = "insert into general_cartoon_order ('".$order_id."','".$_SESSION['cart'][$key]['cartoon_id']."','".$_SESSION['cart'][$key]['date']."','".$_SESSION['cart'][$key]['quantity']."','".$_SESSION['cart'][$key]['size']."','".$_SESSION['cart'][$keys]['price']."')";
	echo $query;
	$result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query");
}
unset($_SESSION['cart']);
header("Location: rmcheckout.php");
exit();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.