PHP / MYSQL不会使用变量更新行

时间:2019-06-22 15:51:53

标签: php mysql sql

我正在尝试在数据库中更新一行。我的查询在我的PHP中运行顺利。但是,我的数据库中没有任何更新。

我尝试弄乱语法和引号,但最终碰壁。这可能是一个简单的事情,我完全忽略了,但却完全空白了。

此外,是的,我知道我很脆弱。那不是我想要的建议。

$insert_cust = "
UPDATE customers 
   SET first_name = '$first_name' 
     , last_name = '$last_name'
     , street_address = '$street'
     , city = '$city' 
     , state = '$state'
     , postal_code = '$zip'
     , country = '$country'
     , status = '$status' 
 WHERE email_address = '$email' 
   AND sess_id = '$sess_id'
";


    // Insert Order

        $ship_to = $first_name . " " . $last_name . ", " . $street . ", " . $city . ", " . $state . " " . $zip . ", " . $country;


     $insert_order = "INSERT INTO orders (email_address, item_name, item_link, stripe_order_id, total_amount, order_bump, bump_link, shipping_address, sess_id)
VALUES ('  $email  ','  $item_name  ', '  $item_link  ', '  $order_id  ', '  $item_price  ', ' $bump ', '  $bump_link  ', ' $ship_to ', '$sess_id')";

if ($conn->query($insert_cust) == TRUE && $conn->query($insert_order) == TRUE) {
    // Next Page
    header('Location: offer2.php');
} else {
    echo "Error: "  . $insert_cust . "<br>" . $insert_order . "<br>" . $conn->error;
}

0 个答案:

没有答案