Like it says on the tin: all of a sudden I can only buy stocks of a single company in pset7. For example, I logged in as John Harvard, and bough 10 shares of Google. I then tried to buy 10 shares of a different company, but instead I had another 10 shares of Google added to my portfolio.
I find this strange, because when I var_dump-ed the variables that I am using in the INSERT statement, they all printed out just as they should be.
The (I hope) relevant snippet of my code is here:
$insert = CS50::query("INSERT INTO portfolios (users_id, symbol, shares) VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE shares = shares + VALUES(shares)", $_SESSION["id"], $stock["symbol"], $_POST["shares"]);
I don't know if this is relevant, but I have implemented the joint key mentioned in the pset spec in my database (so users_id and symbol were together marked as unique).
I've been on this for some time, and tried implementing the above statement in a few different ways, so I'll appreciate help.
EDIT: this is what my 'portfolios' table looks like:
+----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| id | int(10) unsigned | NO | PRI | NULL | |
| users_id | int(10) unsigned | NO | MUL | NULL | |
| symbol | varchar(255) | NO | | NULL | |
| shares | int(10) unsigned | NO | | 0 | |
+----------+------------------+------+-----+---------+-------+