Working with Foreign Keys and having issues

What am I doing wrong? I am trying to create a new foreign key.

How are you setting it up and where do you get this error?

phpMyAdmin

I am using an existing database and trying to add a new table to modify the database to fit my needs

What is your table type? MyISAM doesn’t support foreign keys.

I am using InnoDB, I did create the table first at an MyISAM table but I converted it.

So little more back story, I have a listings table, this is items being sold and now I am creating an events table which will be an single event with several items being sold.

I have set the id in the events table as a Int(11),PK,AI,NOT Null then I went over to the listings table create a new column called event_id setup as Int(11) then index it.

The error comes when I go to create the foreign key constraints.

I am mapping it this way as an listing can only be tie to 1 event but 1 event can be tied to many listings.

There seems to be existing data in the table.
And somewhere there, the value of column you are trying to make foreign key, does not match the values in foreign table.
So just remove those from this table, or add to foreign table, and it should get created.