Hot answers tagged

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 ...
user avatar
  • 3,035
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 ...
user avatar
  • 18.4k
10 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.
user avatar
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 ...
user avatar
5 votes

Problem with query quotes from Yahoo finance

Thank Brenda Anderson from Facebook group CS50 for providing a new code for helpers.py
user avatar
5 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, ...
user avatar
  • 71
4 votes

Pset7 Can't Print How Much Cash a User has?

To solve this issue, you need 2 variables. Let's call them $userinfo and $cash. First use query() to get cash value from the row with the id that is contained in $_SESSION. Then use this line of code ...
user avatar
  • 1,211
4 votes
Accepted

Does CS50 Finance follow MVC design?

I'm not an expert, but apparently it's supposed to be applying MVC. I think the idea behind MVC is dividing the website/web application into 3 interconnected parts. The model (e.g., the database) ...
user avatar
  • 17.4k
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] ...
user avatar
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: ...
user avatar
4 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 ...
user avatar
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 ...
user avatar
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, ...
user avatar
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 ...
user avatar
  • 17.4k
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 ...
user avatar
  • 7,326
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.
user avatar
  • 18.4k
3 votes

Extra feature to send receipts - PHP Mailer not connecting

The problem is really about host(smtp.fas.harvard.edu), I had the same problem and here is my decision: I created a new mailbox at gmail, and used it like this: /*Sends a message of $body with ...
user avatar
3 votes
Accepted

Pset7 How do I log a user in after they register?

The problem is in: $_SESSION["id"] = $row["id"]; it should be: $_SESSION["id"] = $id;
user avatar
  • 1,369
3 votes

Server Error when trying to load CS50 Finance for first time

The Apache2 web server in the current version of the appliance needs a configuration tweak. Please run the following commands in a terminal in your appliance: sudo a2dismod php5 sudo a2enmod suphp ...
user avatar
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.
user avatar
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 ...
user avatar
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. ...
user avatar
  • 20.7k
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.
user avatar
2 votes
Accepted

How to determine how much cash a user has in C$50 Finance's portfolio.php

Yes your logic is correct, and this is exactly the way the world works. Say I have $20. I buy a diamond for $10. So now I have $10 left. In a week from now, the same diamond, costs $5. But I still ...
user avatar
  • 7,326
2 votes

I encountered a `503 Service Unavailable` error while trying to access the staff's implementation of C$50 Finance. How can I resolve this?

A 503 Service Unavailable error is usually a temporary one, as this one turned to be. It usually indicates that the server is either overloaded or undergoing maintenance. The web server is still ...
user avatar
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/
user avatar
2 votes
Accepted

pset7 sell.php has problem

The menu value is not being correctly assigned in the HTML page. The name of the variable needs to be on the element that you want to access. In your code, the menu variable name is assigned to the ...
user avatar
  • 2,625
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 ...
user avatar
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 ...
user avatar
  • 3,035
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 ...
user avatar
  • 3,035

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