gpt4 book ai didi

PHP代码没有将数据输入数据库

转载 作者:行者123 更新时间:2023-11-30 23:55:26 26 4
gpt4 key购买 nike

    $name = $_GET['fullname'];
$phone = $_GET['phone'];
$address = $_GET['address'];
$size = $_GET['size'];
$toppings = $_GET['toppings'];
$delivery = $_GET['type'];



mysql_connect ("localhost", "root", "") or die ('Error: ' . mysql_error());
mysql_select_db ("pizzaorders");
$query ="INSERT INTO orders (fullname, phone, address, size, toppings, delivery) VALUES ('".$name."', '".$phone."', '".$address."','".$size."','".$toppings."','".$delivery.")";
$done=mysql_query($query);
echo $done;

$total = 0;
$total = sizecost() + deliverycost() + toppingcost();

echo " $name your {$_GET["size"]} pizza will come in 45 minutes.";
echo "Total: $ $total";
echo " Your Toppings are ";
foreach($toppings as $topping) {
echo $topping ;
}
echo "Your Delivery Type:{$_GET["type"]}";
echo "Database Updated";

function sizecost() {
$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 toppingcost() {
$toppings = $_GET['toppings'];

foreach($toppings as $topping) {
$topping=1;
$topping=$topping+1;
}
return $topping;
}

function deliverycost() {
$deliverycost = 0;
if ($_GET['type'] == "delivery") {
$deliverycost += 5;
}
return $deliverycost;
}

最佳答案

最后一个值在末尾缺少单引号。

关于PHP代码没有将数据输入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5744273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com