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>
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>®</sup>",
"price" => 11,
"blurb" => "Bacon text",
"drink" => "Club Soda"
),
)
Please help.
Naveen