23
votes
Accepted
can't get the site to run
CS50 course materials will tell you that the permissions need to be set as follows:
chmod 711 for directories
chmod 644 for images, HTML, CSS, JavaScript
chmod 600 for PHP files.
In general, this is ...
19
votes
Accepted
Pset7 - :( quote handles valid ticker symbol
I found a solution here. I didn't format the price of stock by usd(). When I changed my code from {{ price }} to {{ price | usd }} in quoted.html, it worked.
13
votes
Accepted
pset7 finance check50 ':( buy handles valid purchase'
There is nothing in the spec saying to output the purchase price to the user.
That is because such a page is not required.
check50 is parsing your index.html page after it makes one purchase, so it ...
6
votes
Accepted
pwd_context.encrypt Depreciation Warning Pset7
Use hash instead of encrypt in your register function. I tried it, it worked for me. I was able to sign on as an existing user, or register (and sign on as) a new user. I am not advocating blindly ...
6
votes
pset7 fractions being rejected causing Buy to fail
SOLVED. I added the following:
try:
shares = int(request.form.get("shares"))
except ValueError:
return apology("shares must be a posative integer", 400)
I was under the impression that, ...
5
votes
Problem with query quotes from Yahoo finance
Thank Brenda Anderson from Facebook group CS50 for providing a new code for helpers.py
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 ...
4
votes
Accepted
cs50 finance / pset-7 confused on index() table
Since "stocks" are in one list and "currentprices" are in another list you will get this result when you use two lists and two loops.
One solution would be to use one loop and use currentprices[i] ...
4
votes
Accepted
Using jinja to render template based on previous url - pset7 finance
Inside the function for the respective routes you can just call the function "flash(message)" before the "return redirect()" function, where "message" is the message you want to display. for example:
...
4
votes
Accepted
finance 500 internal server error on registration
The last line in the log about errorhandler is a red herring. More on that later; will edit after proper research.
The important line in the log is where it says something about bind parameters (if ...
4
votes
Accepted
Finance: How to check if input is valid in "quote"?
If lookup() doesn't find the requested symbol, it will return None. That is not explicitly stated in the spec, but that is what the try/except block does in the function.
None is not subscriptable, ...
3
votes
Accepted
What does VALUES(shares) refer to in the ON DUPLICATE KEY UPDATE clause?
According to the docs:
You can use the VALUES(col_name) function in the UPDATE clause to
refer to column values from the INSERT portion of the INSERT ... ON DUPLICATE KEY UPDATE statement. In ...
3
votes
Accepted
Non-negative integer check
Let's break it down:
preg_match("/^\d+$/", $_POST["shares"])
I think you can tell that $_POST["shares"] is the variable to be mached and the regex string is /^\d+$/.
The first and last / are the ...
3
votes
Accepted
What is wrong with this SQL command?
As I told you on Slack:
This is the syntax that will work:
"INSERT INTO table(field1,field2,field3) VALUES (?,?,?)", $var1, $var2, $var3);
and replacing the fields and variables as appropriate.
3
votes
Accepted
CSS Having No Affect in PSET7
shift-reload or ctrl-F5 will clear the browser's cache and (should) reload your css file.
3
votes
Pset7 cs50 finance register method not displaying register.html
The post method is only used when you submit a form. Clicking register doesn't count as a post method, therefore you are skipping the entire section of your code in the post conditional, and the code ...
3
votes
Accepted
pset7 finance check50 doesn't detect a valid sale despite portfolio updating correctly
As suggested in a comment, add this to the top of your lookup function in helpers.py
if symbol == "AAAA":
return {"name": "Test A", "price": 28.00, "symbol": "AAAA"}
and then, with a fresh ...
3
votes
Accepted
SQL3 SUM troubles
You can't use the aggregated value in WHERE. WHERE is applied to the table data, and the aggregated values are created later.
There is the complementary HAVING clause, processed after aggregation. ...
3
votes
Accepted
I can't seem to fix or find the error in finance. Can someone help? I realize in index.html the if condition needs to be fixed
Sometimes it's the line before the line that is reported. That is the case here. This line print( len(db_shares ) has unbalanced parens.
2
votes
Accepted
When I run my apache50 server at ~/workspace/pset7/public why does login.php files open?
From the pset instructions:
Know that index.php is the
file that’s loaded by default when you visit a URL like https://ide50-username.cs50.io/.
...which calls (redirects to) login.php (via ...
2
votes
Accepted
I dont really understand what function render($template, $values = []) does
solved via reddit thanks to FReeER for helping me figure out with the long explanations it really helped me
https://www.reddit.com/r/cs50/comments/3m6qp0/i_dont_really_understand_what_function/
2
votes
Accepted
Pset7 Finance: register.php gives me an error
Do not use chmod 777 views/*. That will probably help you to get your site to load, but it is bad for security, and a terrible habit to get into. It's like taking the front door of your house off of ...
2
votes
Cannot get started on pset7
Do not use chmod 777 *. That will probably help you to get your site to load, but it is bad for security, and a terrible habit to get into. It's like taking the front door of your house off of its ...
2
votes
Accepted
Not being able to access CS50 Finance by https://ide50-username.cs50.io/
REVISED 25-sep-2016
Recap Based on the history of this issue, it has been determined that there is "something wrong" with your workspace. The php5 module is not being loaded in apache50, which makes ...
2
votes
should I create a table for every user on buy, cs50 finance
I suggest creating a table, called, for example, transactions. In the table, there are columns: user_id, name of the company, quantity of shares, price of 1 share, date. In this way I will keep ...
2
votes
Pset7 - Finance: Cannot figure out how to loop through values in list/dict in order to display results in rows in html table
What is going to be stored into your holdings value is "A list of dictionaries",
where each list item will be one stock.
i.e each list item will correspond to each row of your query: "SELECT stock, ...
2
votes
Using jinja to render template based on previous url - pset7 finance
How about if you create a new session key, like session['action'] = 'Bought' that gets set in the appropriate route?
2
votes
Accepted
pset7: Help: User always gets logged out
The problem is (probably) in quote.html and buy.html. Likely they have action attribute pointing to login like this <form action="{{ url_for('login') }}" method="post">
2
votes
Accepted
pset7 question about tables in buy
Ok, I may be wrong about this and I can delete my answer so it stays unanswered if I am.
I think the spec is a little murky referenced by Dino on the question linked above. Dino interpreted it to ...
2
votes
Accepted
How to convert a 'list' into an int
From the Hints section of the spec:
If str is a SELECT, then execute returns a list of zero or more dict objects, inside of which are keys and values representing a table’s fields and cells, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
finance × 510pset7 × 198
pset8 × 71
pset9 × 66
cs50x × 62
buy × 50
python × 40
index × 38
register × 38
sql × 35
check50 × 30
flask × 28
sell × 19
html × 16
jinja × 16
web × 15
check × 13
application.py × 13
login × 12
php × 11
cs50x2017 × 11
financepset9 × 11
quote × 10
error × 9
cs50-ide × 9