http://localhost/bradhusey/dish.php?item=Club-sandwich"

Hi,

I am trying to learn some coding and I think I made it quite far. Just got stuck now.

I have the folowing PHP code:

[php]<?php
define(“TITLE”, “Menu : Franklin’s Fine Dining”);
include(‘includes/header/php’);

    function strip_bad_chars( $input ) {
        $output = preg_replace("/[^a-zA-Z0-9_-]/", "", $input);
            return $output;
    }
            if (isset($_GET['item'])) {
        $menuItem = $_GET['item'];
        $dish = $menuItems[$menuItem];
    }

   // Calcuate Tip 
    Function suggestedTip($price, $tip) {
        $totalTip = $price * $tip;
        echo money_format('%.2n', $totalTip);
    }

?>


$<?php echo $dish[price]; ?>

<?php echo $dish[blurb]; ?>


<p> <strong>Suggested Beverage: <?php echo $dish[drink]; ?> </strong>    </p>
<p><em>Suggested Tip: <sup>$</sup><php suggestedTip ($dish[price], 0.0); ?> </em></p>    
[/php]

When I click on the link it gives me the following error message:

====================
Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost
Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.15

Hint (?):
When I look at how the teacher has done it, I can see that there is no " at the end of what he has in the URL

http://localhost/bradhusey/dish.php?item=Club-sandwich"

i.e. after the word sandwich there are not quotes. I tried everything but now I am stuck.

Please see the code of the arrays:

// Menu Items
$menuItems = array (
“Club-sandwich” => array(

                                            "title" => "Club Sandwich",
                                            "price" =>    11,
                                            "blurb" => "Bacon text",
                                            "drink" => "Club Soda"                            
                                
                            ),
        
                            "Dill_Salmon" => array(
                                            
                                            "title" => "Lemon and Dill Salmon",
                                            "price" =>    18,
                                            "blurb" => "Pork text",
                                            "drink" => "Fancy wine"                            
                                
                            ),
        
                            "Super-Salad" => array(
                                            
                                            "title" => "Super-Salad<sup>&reg;</sup>",
                                            "price" =>    11,
                                            "blurb" => "Bacon text",
                                            "drink" => "Club Soda"                            
                                                              
                                
                                
                            ),
        
    )

Please help.

Naveen

Hint (?): When I look at how the teacher has done it, I can see that there is no " at the end of what he has in the URL

http://localhost/bradhusey/dish.php?item=Club-sandwich"

Where is the portion of code that has the form? My thought is, you are doing something like this,

[php]

"'><?php echo $menuItems['title']; ?> [/php]

Well, Brad, since you did not show us your anchor () code, we can not help you with it. Also, if you
have a teacher involved, you might want to ask him.

Now, with that said, a normal link is created something like this: Text-to-show
The href is the address that you want the user to be switched to if they click on the text. If you click on this
link, it should show the page’s href in the address bar of your browser. It should show you what is wrong.

Normally, you would not put in an href like: http://localhost/bradhusey/dish.php?item=Club-sandwich"
Instead, it would just be the new page you want to switch to like: dish.php?item=Club-sandwich
Unless you need to use a full URL for some server reason. But, if your code is adding in an extra double
quote, just locate where it is adding it and remove it…

Hope that helps some…

Sponsor our Newsletter | Privacy Policy | Terms of Service