It seems like every hour I have another question I can't seem to figure out with pset7 :( I'm sorry to whoever is kindly answering all of these queries and I appreciate the help a lot! I know at least one other person who has had a similar undefined index problem, too, and am wondering if something might be causing it that I just don't have the knowledge base to figure out.
I am trying to get portfolio.php to work but for some reason my queries don't seem to be working. Right now I have:
$row = query("SELECT symbol, shares FROM Portfolio WHERE id=?", $_SESSION["id"]);
$cash = query("SELECT cash FROM users WHERE id=11", $_SESSION["id"]);
I keep being told cash is an undefined index and when I try to print it out as a test it doens't work. furthermore, when I pass the values as $positions to portfolio.php (a template) with this code:
render("portfolio.php", ["title" => "Portfolio", "positions"=>"$positions", "cash"=>"$cash"]);
And then I do foreach ($position as $positions)
I get told position is an undefined variable. So even though that one seems to exist in index.php it doesn't work in portfolio.php, while cash works in neither. I re-watched the videos many times but can't seem to find a typo in the code above. I have tried putting the variables in render in and out of quotes (just because I had to try something) but it made no difference.
var_dump($positions)
? – skreborn Jun 21 '14 at 12:36