A new issue start to show on my site


#1

My web site is called mypos-demo , it was working good for 2 months till the last days , it start to get a database error one creating a raw " a foreign key constraint fails " .
i checked the code and tried it in local server and it is ok ( i even didn’t changed it since i uploaded it and it was working great as i said before ) , i even tried to insert the row from phpmyadmin , and it also give me the same error !! , checked the id of the inserted key and it is exists so i didn’y find a problem in my code or in my database it self ( again the site was working great till the last days ) the last time it is great was on 31 Dec , from then the problem started to raise

So please tell me what is the problem , is it a problem in the services all or what ?


#2

Please try disabling foreign key checks. :slight_smile:


#3

Thanks will do , but why suddenly this happened ?


#4

Have disabled foreign key check and the problem still show up,
here is a screen shot from phpmyadmin


#5

Good day!

product_id is an index, therefore its value must be unique. Make sure you’re not inserting a record which is already recorded with the same value in product_id


#6

First Thanks for your replay
yes it is an index but not an unique key , an index help in making searching and query faster on a database nothing to do with insert or update record and as i said in the topic the database is working great for 2 months no problem to show , and here it is a screenshoot of the table with the records in it ( and not unique product_id ) , the problem started to show up from the 1st Jan don’t know the reason of that , but it is not in the code (even phpmyadmin show the same error ) or the database struct it self because it worked great before and on other hosts !

I removed the foreign key at all ( tried to disabled it but not working ) it is not a solution but i want my site to work again as expected


#8

I have modified the configuration. Please try performing the same query again.


#9

Thanks for your support , i add the foreign key again and it worked


#10

We’re happy the problem has been solved! :slight_smile:


#11