Je reçois cette erreur:Obtenir Erreur fatale
Fatal error: Unsupported operand types in C:\xampp\htdocs\process.php on line 59("$total = calculate_size_cost() + calculate_topping_cost() + calculate_delivery_cost();")
<?php
$name = $_GET['name'];
$phone = $_GET['phone'];
$address = $_GET['address'];
$size = $_GET['size'];
$topping = $_GET['topping'];
$delivery = $_GET['deliverytype'];
$comment=$_GET['comments'];
mysql_connect ("localhost", "root", "") or die ('Error: ' . mysql_error());
mysql_select_db ("pizza");
$query ="INSERT INTO orders (name, phone, address, size, topping, delivery, comments) VALUES ('".$name."', '".$phone."', '".$address."','".$size."','".$topping."','".$delivery."','".$comment."')";
$total = 0;
$total = calculate_size_cost() + calculate_topping_cost() + calculate_delivery_cost();
echo "Dear $name your {$_GET["size"]} pizza has been ordered.";
echo "Your Total is $ $total";
echo "\n\n\nYour Toppings: {$_GET["topping"]}";
echo "\nYour Comments: {$_GET["comments"]}";
echo "Your Delivery Type:{$_GET["deliverytype"]}";
function calculate_size_cost() {
$size = 0;
if ($_GET['size'] == "Small"){
$size+=5;
}
else if ($_GET['size'] == "Medium"){
$size+=10;
}
else if ($_GET['size'] == "Large"){
$size+=15;
}
return $size;
}
function calculate_topping_cost() {
$topping = 1;
return $_GET['topping'];
}
function calculate_delivery_cost() {
$delivery_cost = 0;
if ($_GET['deliverytype'] == "delivery") {
$delivery_cost += 5;
}
return $delivery_cost;
}
?>
Que contient '$ _GET ['topping']'? –
Je suppose que $ _GET ['topping']; ce n'est pas un nombre :). –
Il contient la valeur de $ topping. – Ankur