callisto11 Posted July 16, 2008 Share Posted July 16, 2008 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 https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/ Share on other sites More sharing options...
awpti Posted July 17, 2008 Share Posted July 17, 2008 Contact the developer of the application. Link to comment https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/#findComment-592093 Share on other sites More sharing options...
darkfreaks Posted July 17, 2008 Share Posted July 17, 2008 i would be happy to assist if you pasted more code Link to comment https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/#findComment-592099 Share on other sites More sharing options...
callisto11 Posted July 17, 2008 Author Share Posted July 17, 2008 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 https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/#findComment-592114 Share on other sites More sharing options...
darkfreaks Posted July 17, 2008 Share Posted July 17, 2008 remove the @ it supress error Link to comment https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/#findComment-592132 Share on other sites More sharing options...
callisto11 Posted July 17, 2008 Author Share Posted July 17, 2008 To darkfreaks, It still giving the same error! Link to comment https://forums.phpfreaks.com/topic/115132-a-sql-error-message-on-my-website-pls-im-new-to-php-and-sql/#findComment-592134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.