gpt4 book ai didi

php - 从表中删除 (*php 变量*) 中的 id 返回错误

转载 作者:行者123 更新时间:2023-11-29 12:49:00 25 4
gpt4 key购买 nike

我在一个 php 应用程序中工作,我必须从列表中删除所选项目,其中每个项目都有自己的 mysql 数据库 ID,一切正常,直到在 php 中执行查询。

这是错误消息:

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 5

这是我在查询中执行的字符串:

$queryDE =  "delete from md5_agenda
where id_empresa = $empi
and id_unidade = $unii
and id_usuario = $usrr
and id_item_agenda in ($deletar);"

变量$deletar从post方法接收它们的值,它们的值类似于:35,​​36,47,...并且可以是一个或多个不同的值

但我的问题是,如果我将 $deletar 更改为确切的值,一切都会正常,但如果我使用具有完全相同值的 php 变量,它将不起作用并返回之前的错误消息,我不知道该怎么做...我想保持这种方式,我可以选择我想要删除的所有 ID,而无需重复查询。

谢谢。

编辑: the echo returns the $queryDE and the mysql_error()

最佳答案

foreach($deletar as $val)
{
$queryDE = "delete from md5_agenda
where id_empresa = $empi
and id_unidade = $unii
and id_usuario = $usrr
and id_item_agenda = $val;"
}

your code is not working because $deleter is return multiple value.
check code it's working.

关于php - 从表中删除 (*php 变量*) 中的 id 返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25036484/

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