adam291086 Posted March 11, 2009 Share Posted March 11, 2009 i am trying to update my mysql table and i am getting the error SQL/DB Error -- [Cannot add or update a child row: a foreign key constraint fails (`adamplo1_CASE/persons`, CONSTRAINT `fk_Persons_EducationLevels` FOREIGN KEY (`EducationLevels_idEducationLevel`) REFERENCES `education_levels` (`idEducationLevel`) ON DELETE NO ACTION ON UPDA)] this is my php query result UPDATE `persons` SET `idUser` = 'null',`username` = '\'Adam\'',`password` = '\'plowman\'',`title` = '\'Mrtyjghjgh\'',`forename1` = '\'Adam\'',`forename2` = 'null',`surname` = '\'Plowman\'',`addressLine1` = 'null',`addressLine2` = 'null',`town` = 'null',`postcode` = 'null',`secondEmail` = 'null',`personalUrl` = 'null',`female` = '\'1\'',`photo` = '\'\'',`postcodeStart` = 'null',`authorityToWorkStatement` = 'null',`contactPreference` = '\'Mobile\'',`EducationLevels_idEducationLevel` = 'null',`noOfGcses` = '\'000\'',`gcseEnglishGrade` = 'null',`gcseMathsGrade` = 'null',`fiveOrMoreGcses` = '\'null\'',`noOfAlevels` = '\'0000\'',`ucasPoints` = '\'0000\'',`studentStatus` = '\'Full-time\'',`mobile` = 'null',`landline` = 'null',`dob` = 'null',`penaltyPoints` = 'null' WHERE `idUser` = 1 Link to comment https://forums.phpfreaks.com/topic/148978-solved-php-mysql-update-with-foreign-keys/ Share on other sites More sharing options...
adam291086 Posted March 11, 2009 Author Share Posted March 11, 2009 bump Link to comment https://forums.phpfreaks.com/topic/148978-solved-php-mysql-update-with-foreign-keys/#findComment-782460 Share on other sites More sharing options...
redarrow Posted March 11, 2009 Share Posted March 11, 2009 You must be using a INNODB style database and you've placed constraints on key::foreign key relationships in a way that prevents you from changing the foreign key to a value that does not have a match in the parent table. post your table, are u using two increments if so it un safe. Link to comment https://forums.phpfreaks.com/topic/148978-solved-php-mysql-update-with-foreign-keys/#findComment-782463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.