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`))

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();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.