1

我有两个 mysql 表,这里是他们的 sql =>

我正在用它的子菜单制作动态菜单。所以我有想要执行这样一个查询的情况

DELETE FROM artinfo WHERE descName=(SELECT for_sub_url FROM menu WHERE menu_id=" . $_POST['main_menu_titles'] . ")

其中$_POST['main_menu_titles']存在并且是 menu_id。我也没有编写 php 代码,因为它工作得很好而且值得注意的是,当我试图从 mysql shell 执行它时执行这个查询(当然直接使用 menu_id 的数字而不是 $_POST['m_num'])

任何想法发生了什么,如何从 php 脚本执行它?谢谢 :)

更新

这是php脚本

if ($connection->query("DELETE FROM artinfo WHERE descName=(SELECT for_sub_url FROM menu WHERE menu_id=" . $_POST['main_menu_titles'] . ")") && $connection->query("DELETE FROM artinfo WHERE descName IS NULL AND cat_id=" . $_POST['main_menu_titles'] . "")){
                            $edit_res_fine = "DELETED";
                        }
4

2 回答 2

0

If you say the query works just fine without $_POST, I would think the code in question is located in the form you submit to acquire $_POST['main_menu_titles']. To test the correct value is being sent, try echoing the value of $_POST['main_menu_titles'] right before the query.

于 2012-07-30T19:34:05.497 回答
-1

尝试这个。

$query = "DELETE FROM artinfo WHERE descName = (SELECT for_sub_url FROM menu 
WHERE menu_id = '" . $_POST['m_num'] . "')";
于 2012-07-30T19:32:59.733 回答