Your HostICan Community  


Go Back   Your HostICan Community > Programming & Design > PHP / MySQL Assistance
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

PHP / MySQL Assistance We understand. Not all of you are experienced programmers, but some of you are highly skilled at coding. So we've set aside this forum so you can ask questions, and provide answers to the most commonly asked PHP / MySQL issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2008, 08:42 PM
Junior Member
 
Join Date: May 2008
Posts: 2
Default Error executing query

I have been trying to structure/populate a database using a SQL file provided by the makers of a script. I have been entering the the queries into the SQL tab for the appropriate database using phpMyAdmin. I can successfully execute the queries which create the tables and create the foreign keys. I can also successfully execute the first few (of many) queries which insert the sample data.

Unfortunately, I get the following error whenever I run some of the subsequent INSERT INTO queries:
Code:
MySQL said: 

#1452 - Cannot add or update a child row: a foreign key constraint fails (`nodomain_jobomagedb/catalogindex_eav`, CONSTRAINT `FK_CATALOGINDEX_EAV_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE)
Here is a sample of on of the failed queries (see attachment for full query):
Code:
INSERT INTO `catalogindex_eav` (`index_id`, `store_id`, `entity_id`, `attribute_id`, `value`) VALUES
(1, 1, 16, 272, 24),
(2, 1, 16, 102, 20),
(3, 1, 16, 273, 1),
(4, 1, 16, 274, 2),
(5, 1, 17, 272, 23),
(6, 1, 17, 102, 21),
(7, 1, 17, 273, 1),
(8, 1, 17, 274, 2),
(9, 1, 18, 272, 24),
(10, 1, 18, 102, 2),
(11, 1, 18, 273, 1),
(12, 1, 18, 274, 2),
(13, 1, 20, 272, 23),
(14, 1, 20, 102, 3),
(15, 1, 20, 273, 1),
(16, 1, 20, 274, 2),
(17, 1, 25, 272, 23),
(18, 1, 25, 273, 1),
(19, 1, 25, 274, 2),
(20, 1, 25, 510, 77),
(21, 1, 26, 272, 24),
(22, 1, 26, 273, 1),
(23, 1, 26, 274, 2),
(24, 1, 26, 510, 79),
(25, 1, 27, 272, 24),
(26, 1, 27, 273, 1),
(27, 1, 27, 274, 2),
(28, 1, 27, 510, 76),
(29, 1, 28, 272, 24),
(30, 1, 28, 273, 1),
(31, 1, 28, 274, 2),
(32, 1, 28, 510, 74),
(33, 1, 19, 272, 23),
(34, 1, 19, 102, 101),
(35, 1, 19, 273, 1),
(36, 1, 19, 274, 2),
(37, 1, 39, 272, 22),
(38, 1, 39, 273, 1),
(39, 1, 39, 274, 2),
(40, 1, 39, 501, 65),
(41, 1, 39, 525, 99),
(42, 1, 40, 272, 59),
(43, 1, 40, 273, 1),
(44, 1, 40, 274, 2),
(45, 1, 40, 508, 71),
(46, 1, 41, 272, 59),
(47, 1, 41, 273, 1),
(48, 1, 41, 274, 2),
(49, 1, 41, 508, 71),
(50, 1, 42, 272, 59),
(51, 1, 42, 273, 1),
(52, 1, 42, 274, 2),
(53, 1, 42, 508, 71),
(54, 1, 44, 272, 24),
(55, 1, 44, 102, 34),
(56, 1, 44, 273, 1),
(57, 1, 44, 274, 2),
(58, 1, 44, 513, 90),
(59, 1, 45, 272, 23),
(60, 1, 45, 102, 32),
(61, 1, 45, 273, 1),
(62, 1, 45, 274, 2),
(63, 1, 45, 513, 93),
(64, 1, 46, 272, 23),
(65, 1, 46, 102, 33),
(66, 1, 46, 273, 1),
(67, 1, 46, 274, 2),
(68, 1, 46, 513, 91),
(69, 1, 47, 272, 23),
(70, 1, 47, 102, 34),
(71, 1, 47, 273, 1),
(72, 1, 47, 274, 2),
(73, 1, 47, 513, 90),
(74, 1, 48, 272, 23),
(75, 1, 48, 102, 31),
(76, 1, 48, 273, 1),
(77, 1, 48, 274, 2),
(78, 1, 48, 513, 93),
(79, 1, 51, 272, 26),
(80, 1, 51, 273, 1),
(81, 1, 51, 274, 2),
(82, 1, 51, 508, 72),
(83, 1, 52, 272, 26),
(84, 1, 52, 273, 1),
(85, 1, 52, 274, 2),
(86, 1, 52, 508, 72),
(87, 1, 53, 272, 26),
(88, 1, 53, 273, 1),
(89, 1, 53, 274, 2),
(90, 1, 53, 508, 72),
(91, 1, 54, 273, 1),
(92, 1, 54, 274, 2),
(93, 1, 54, 508, 72),
(94, 1, 54, 272, 26),
(95, 1, 54, 273, 1),
(96, 1, 54, 274, 2),
(97, 1, 54, 508, 72),
(98, 1, 54, 272, 26),
(99, 1, 54, 273, 1),
(100, 1, 54, 274, 2),
(101, 1, 54, 508, 72),
(102, 1, 54, 272, 26),
.
.
.
.
(433, 6, 133, 273, 1),
(434, 6, 133, 274, 2),
(435, 6, 132, 273, 1),
(436, 6, 132, 274, 2),
(437, 6, 134, 273, 1),
(438, 6, 134, 274, 2);
This fails whether I run the full query above or whether I simplify it to include only the first row. I first thought that this was a syntax error in the SQL but other user's of the script have run this query without problems on their hosts.

Is there something about the way Hostican has their SQL server set up which is preventing this query from executing successfully?

Thanks for any help.

Bob
Attached Files
File Type: txt SQL_insert_error.txt (10.1 KB, 1 views)
Reply With Quote
  #2 (permalink)  
Old 05-15-2008, 04:06 AM
dele454's Avatar
Junior Member
 
Join Date: Apr 2008
Posts: 10
Default

There is obviously a constraint infringement hence the error flagged. it seems you are inserting an ID into 'catalogindex_eav' that doesnt exist in 'catalog_product_entity' hence the constraint error flagged. You need to make sure that for PK>FK relationships FK values entered must exist on the parent table PK. - data integrity

Last edited by dele454 : 05-15-2008 at 04:11 AM.
Reply With Quote
  #3 (permalink)  
Old 05-15-2008, 05:49 PM
Junior Member
 
Join Date: May 2008
Posts: 2
Default

It is apparently a known issue with phpMyAdmin - the SQL import works fine through a shell.

Bob
Reply With Quote
  #4 (permalink)  
Old 05-16-2008, 12:17 PM
dele454's Avatar
Junior Member
 
Join Date: Apr 2008
Posts: 10
Default

interesting...
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:27 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

Copyright © 2003 - 2008 HostICan. All Rights Reserved.