0

So I'll start easy with quote.php. It works if I give the correct symbol, and correctly apologizes if i leave the form blank. But any invalid symbols seems to allow for render to work on quote_display... Here is my code. I defined quote_display to be render(quote_display.php) with necessary parameters.

// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{

    $stock = lookup($_POST["symbol"]);


    if ( $stock !== false)
    {
         quote_display($stock);  
    }
    else
    {
        apologize("Invalid stock entered");
    }



}
else
{
    // else render form
    render("quote_form.php", ["title" => "Quote"]);
}

2 Answers 2

0

One way I can imagine the behaviour you describe is if $_POST["symbol"] contains a valid symbol. For a rudimentary "eye-check" you could add a var_dump($_POST["symbol"]); before "$stock =....".

Does it behave differently if you lookup an invalid symbol first thing? Does quote_display($stock) fail in some way? Does it render something?

1
  • It renders exactly what I type in, like apologize doesnt work it just says at the top of the screen "string 'why is this not working'. Quote_display doesn't do anything really to impact this, it just calls render. The problem is that lookup is actually returning the stock. i think its a bug with lookup the function
    – Fijj01
    Nov 4, 2015 at 20:52
0

Thanks DinoCoderSaurus. I did var_dump on $stock, and found out that it is returning 'N/A' instead of false on $stock['price'] and $stock['name']. So I just changed my if statement to reflect that. All fixed!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .