gpt4 book ai didi

PHP 从表中退休错误

转载 作者:行者123 更新时间:2023-11-29 13:24:04 27 4
gpt4 key购买 nike

我正在尝试从数据库中删除用户记录,我想从表中删除用户的所有附属信息,并且我有以下 php 代码用于从我的 mysql 数据库中删除记录。

function delete_records($array_refer)
{
global $link;
foreach ($array_refer as $key => $array_value) {
$table_name = substr($key, 0, -3);
foreach ($array_value as $value) {
$delete = "DELETE from $table_name where $key = $value";
$exec_delete = @mysqli_query($link, $delete);
if (!$exec_delete) {
rollback_die("Records from $table_name could not be deleted because of: ".mysqli_error($link));
}
}
}
return true;
}

@mysqli_query($link, "SET AUTOCOMMIT=0");
$select_sui = "SELECT
shirt_users.*,
shirt_users_types.*,
shirt_orders.*,
shirt_shipping_addresses.*,
shirt_billing_addresses.*,
shirt_credit_cards.*
FROM shirt_users
LEFT JOIN shirt_users_types ON shirt_users.shirt_users_id = shirt_users_types.shirt_users_id
LEFT JOIN shirt_orders ON shirt_users_types.shirt_orders_id = shirt_orders.shirt_orders_id
LEFT JOIN shirt_shipping_addresses ON shirt_orders.shirt_shipping_addresses_id = shirt_shipping_addresses.shirt_shipping_addresses_id
LEFT JOIN shirt_billing_addresses ON shirt_orders.shirt_billing_addresses_id = shirt_billing_addresses.shirt_billing_addresses_id
LEFT JOIN shirt_credit_cards ON shirt_orders.shirt_credit_cards_id = shirt_credit_cards.shirt_credit_cards_id
WHERE
shirt_users.shirt_users_id = $shirt_users_id";

$exec_select_sui = @mysqli_query($link, $select_sui);

当我运行此程序时,我收到以下错误消息:

The shirt_users_id is:4
Records from shirt_users_types could not be deleted because of:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

知道这意味着什么吗?我知道从衬衫_用户_类型检索数据时存在问题,但我没有看到它警告我的任何语法错误?

最佳答案

$key$value 是否存在并且它们不是保留字吗?您还应该尝试'$value'

关于PHP 从表中退休错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20380599/

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