Hot answers tagged

5 votes
Accepted

CS50 PSET7 Finance: in SELL; expected to find select field with name "symbol", but none found

The form has an input element whose name is "symbol". The spec requires a select element. Require that a user input a stock’s symbol, implemented as a select menu whose name is symbol. Here is doc ...
DinoCoderSaurus's user avatar
2 votes
Accepted

Pset7 undefined index

the notice tells you what exactly the problem is -- there's no index called "shares" in stocka. recall that query returns an array of rows, even if the result was a single row, in which case it would ...
kzidane's user avatar
  • 17.7k
2 votes

pset7 sell.php doesn't sell stocks or change cash

if you look at your sell_form.html, you will find that at this line <option value="symbols"><?= $total["sellsymbol"] ?></value> you have an attribute value set equal to "symbols" ...
Muhammed Othman's user avatar
1 vote

can't seem to figure out the problem with the sell route code

It looks like the value of "cash" in index is the problem. This update = cash[0]["cash"] + eva["price"] seems wrong (based on the UPDATE users SQL): it is adding the ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset 8 finance: :( sell handles valid sale

check50 is looking to see that if you bought, say, 5 shares of ABC and then sold 3 shares, your index page will show the remaining 2 shares with a value using the current quote. (since that is what ...
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

pset8 finance: Problem with calculaton for "/sell"

I suspect you copied buy.html to create sell.html form. I also suspect the form action was not updated to "/sell". The first query in the "strange" does not exist in this sell function. It would ...
DinoCoderSaurus's user avatar
1 vote
Accepted

PSET7 Finance- Quote and Buy not passing all checks

Your guess: is that it has something to do with a rounding error as it is looking for a specific number. is probably right. Usually using the 'usd' function in helpers.py will fix that right up....
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset7 Sell stockprice not a bound parameter

You forgot the : for :stockprice in VALUES (:userID, :symbol, :shares, :amount, stockprice). And to quote Cliff B: If this answers your question, please click on the check mark to accept. Let's ...
Peter Pesch's user avatar
1 vote
Accepted

after using style50 and correcting my spaces etc I ran my code again and got this error which makes no sense to me. need some help please?

Problem is with line db.execute("INSERT INTO history(symbol, shares, price, moment, id) VALUES(: symbol, : shares, : price,: moment, : id)", symbol=info["symbol"], shares=shares, price=usd(info["...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

problem , yet again in pset7 . my sell page works fine but check50 shows me something else O.o

Those errors all mean that there's an earlier test that failed and has to be corrected before the remaining tests can run.
Cliff B's user avatar
  • 68.4k
1 vote

pset 7 sell Type Error 'NoneType' object

Your guess is correct: the lookup function isn't finding symbol. The problem is here <option value = "Symbol">{{ stock.symbol }}</option></option>. "symbol" will always have the ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 sell: can not make drop down menu work

Just after I posted a question i got it. I should put all data manipulations under else from request.method == "POST".
andy's user avatar
  • 11
1 vote
Accepted

pset7 sell.php I seem to be missing something

It is right. CS50::query() always returns an array of rows, even when the result is just one row. That's why you should use the [0], as you have correctly done. You can ctrl+F this: // first (...
Yuri Laguardia's user avatar
1 vote
Accepted

Pset7 pass data to drop down bottom

The query returns what? An array. From Pic 1, $rows looks like this: $rows[0]["symbol"] = "ATT"; $rows[1]["symbol"] = "MMM"; $rows[2]["symbol"] = "X"; At the foreach in Pic 2, $stocks is an array ...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 unsupported operand types

Maybe the problem isn't $ticker[0]["shares"]; there are two operands in the statement. From the spec: Assuming the value of $_POST["symbol"] is a valid symbol for an actual stock, lookup will ...
DinoCoderSaurus's user avatar
1 vote
Accepted

sell.php doesn't return error when the stocks doesn't exist in the user's portfolio

// to make sure the stock is in the user's stocks $rows = CS50::query("SELECT symbol FROM stocks WHERE id = ? AND symbol = ?", $_SESSION["id"], strtoupper($_POST["stock"])); if ($rows["symbol"] === ...
hotwebmatter's user avatar
  • 3,050
1 vote

I am currently working on sell.php. I have debugged the code several times but I am unable to find the error.?

You are using the wrong return value. From the pset specs: If query is instead passed a DELETE, INSERT, or UPDATE statement, it will return a non-negative integer that represents the number of ...
ronga's user avatar
  • 1,415
1 vote
Accepted

pset7 sell: MVC problem

Looks like you're mixing up your view and controller, which appear to be sell_view and sell_index, respectively. If so, sell_index should contain all the php code from querying mysql, storing the ...
ronga's user avatar
  • 1,415
1 vote

Pset7 - Issue with updating cash in sell.php

In the line $funds = $money[0]["cash"]; you are trying to access first element of $money array. However, $money is not defined as an associative array, it just contains a numeric value.
ronga's user avatar
  • 1,415
1 vote

Pset7 Sell.php not adding money to users

To get the price per share, try: $price=$temp_array["price"]; and to get number of shares, remember that query returns an array, and you want the 1st (index=0) row. So try: $numshares=$temp_array2[...
ronga's user avatar
  • 1,415
1 vote
Accepted

pset7 sell controller issue: undefined index

This means that $positions array don't have the key value in it. Check isset($positions["value"]) before hand.
Aboalnaga's user avatar
  • 189

Only top scored, non community-wiki answers of a minimum length are eligible