Earlier today, I was trying to print out how much cash a user has for portfolio.php. I kept on getting a bunch of errors. I changed my code many times, but could never get rid of the errors I was getting- undefined index, use of undeclared constants, etc. How do you fix the errors and print out how much cash a user has?
1 Answer
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 to put the cash value into $cash
.
$cash = $userinfo[0]["cash"];
Then you can put cash in print, and it will print out the user's cash.