0

Im adding a row to a database using a form but I keep getting the following error

Cannot add or update a child row: a foreign key constraint fails (`gigs`.`gig`, CONSTRAINT `gig_ibfk_2` FOREIGN KEY (`act`) REFERENCES `act` (`id`))

I understand the problem, that the database can't add the form because it can't reference the table ACT_id

But when I add the act ID to the form it doesn't work, this is the php I have been using

$query=mysqli_query($conn,"insert into gig SET venue='$gigvenue', act='$actid', sname='$gigdescription', img='$bandimg', start='$gigstart'") or die(mysqli_error($conn));
Emissary
  • 9,954
  • 8
  • 54
  • 65
user3080562
  • 103
  • 1
  • 10

1 Answers1

0

I'm not too good with SQL, but isn't putting $actid in '' making SQL think it's a string? try dropping the quotes (I assume you're inserting a valid ID).

Terax
  • 130
  • 5
  • The only other thing I can think of: echo $actid; and see if this ID is actually inside the act table. – Terax Apr 22 '14 at 18:15
  • $actid is a form element in html, user inputs it. I have made the value to an ID that I'm 100% is in the parent table – user3080562 Apr 22 '14 at 18:30