0

Whenever I try to buy or sell, I get this:

Fatal error: Duplicate entry '11' for key 'PRIMARY'

(if 11 is the ID I'm using.)

I'm not exactly sure where I'm going wrong, in my code or in making the table on phpMyAdmin. So now whenever I buy shares, they go into the row of ID '0' in portfolio, which I didn't assign a user_id to...

1
  • Would need to see the code related to this as well as the sql code that describes how the table was made and any indexes and keys on the table.
    – Cliff B
    Commented Jul 28, 2016 at 2:18

1 Answer 1

-1

It worked when I turned off the PRIMARY key for my id in the History table!

1
  • 1
    yes, but I bet you can now have duplicate entries for the same user and stock symbol. There should be a primary or unique key on the combination of the userid (or id) and symbol columns to prevent multiple entries for the same symbol and userid combination.
    – Cliff B
    Commented Jul 28, 2016 at 4:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .