Jump to content

[SOLVED] php mysql update with foreign keys


adam291086

Recommended Posts

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

 

 

 

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.

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.