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 ...
2
votes
Pset7 buy portfolio values are null
buy should not contain a session["user_id"] =, you would overwrite the user id of the current session that way. The only place for that is login. That might be what causes the error message, you ...
2
votes
Accepted
Pset7 buy portfolio values are null
I can see a couple of things that you may consider changing and also most of your code is correct,so just few things to add on!
The code where you are inserting values after checking that cash > ...
2
votes
Accepted
Pset7 Table HTML and CSS formatting
The render() function takes two arguments, the first is a string that indicates the name of the template, and the second is an array of key-value pairs.
In this case "positions" is a string that ...
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 ...
1
vote
Finance Portfolio (index) I can't go on. Need to take to HTML the actual price and total of stock
Suggest you add the desired fields to the portfolio dicts. In the for row in portfolio: loop, something like row['name'] = share['name'] for example. When portfolio is sent to the html, each row will ...
1
vote
Accepted
pset7 finance portfolio table won't update with buy function
Have you looked at all of the error or other messages returned? The portfolio table has 6 fields, all of which are NOT NULL and don't appear to have defaults, but the insert and update sql code only ...
1
vote
Accepted
pset7 buy function stopped working... not inserting to portfolio
I have a number of questions that may answer your issue.
Does it still work if you create a new user and "buy" a new stock?
Does it work for an old user and a new stock that nobody has bought?
Does ...
1
vote
Accepted
Pset7: How to get "Bought!" Alert in /Index when re-directing from /Buy (I tried IF condition, but failed)
@dinocodersaurus's link :)
flash ("Bought")
return redirect(url_for("index"))
1
vote
Accepted
PSET7: Extracting strings from queries with PHP
You have answered yourself:
Is it because the rows themselves are associative arrays, and so I can
never actually extract a single value? If that's the case, how would I
just pass one variable ...
1
vote
Accepted
Pset7 - Portfolio: $positions not filling
Oh. My. Goodness. My 2nd test condition wasn't a valid stock (just some random capital letters that I thought looked like an actual stock symbol) so
if ($stock !== false)
would kill the foreach() ...
1
vote
Accepted
Fatal error: Table 'pset7.portfolio' doesn't exist in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 352
I know you said that you have already done this, but please open a new Terminal tab in ide50, and execute the following commands:
mysql50 shell
SHOW DATABASES;
USE `pset7`;
SHOW TABLES;
exit
Then ...
1
vote
pset7 portfolio query error
There is no way anyone was going to get this with what I posted. I think the problem comes from the fact that I copy and pasted this from notes I was taking on Zamyla's video.
The key came when I ...
Only top scored, non community-wiki answers of a minimum length are eligible