Mysql PHP and foreign keys

Soldato
Joined
6 Apr 2008
Posts
3,352
Location
Reading
Im writing a database for departmental equipment loans for my university as my final year project. Im an electronic and electrical engineering student with a larger interest in software than hardware as \Ive discovered over the few years of my degree.

For my final year project as said earlier i need a php interface with mysql back end.

I have written the basic database however now Im coming to writing the php to enter information into the database I have come unstuck on one thing. How do I enter into a field that is a foreign key referenced from another table mysql throws a wobbly when doing anything I have tried. So far Im kind of working around it but how do I go about using this properly.

Thanks in advance Edd :)
 
its a bit messy and I dont want to get slated lol. Im using a basic form to collect data then passing it to mysql after serious ammount's of ereg's for error checking. I do Intend to use a selection list taken from the parent table of the foreign key, But thought ill hash it up quickly to enter some data using a form as it would only be sending the same information to the query in the end. however this doesnt work. any special way to input data to foreign key fields?
 
yup innoDB is being used, a further update today, to prove that this is the error causing my form to crash i tried manually inserting the data via mysql cmd prompt. this is the error i get back.

Picture1-3.png
 
might have found it whilst taking a screeny for you, both are varchars but of varying maximum length will test and get back to you. thanks a million for your time :)

edit: yup that was it! what a muppet!!!
 
Back
Top Bottom