Foreign key failure

I have a form app. I used the insert button to create the record and it worked fine

I then decided not to use the insert button, but rather created a PHP button that did nothing more than insert the record using PHP. It fails due to foreign key. Why might this happen? Is there a difference between the SC Insert and my SC insert code?

🚀 Scriptcase 9.12 is now available! Check out the new features here 👉🚀 Next Monday (02/24), Scriptcase 9.12 will be released! Check out the new features before anyone else 👉