dongmimeng5500 2015-07-09 17:07
浏览 38
已采纳

php mysqli prepared statement删除查询问题

I have made a page to remove different elements of my site, but for some reason it's not working... Event though i set the fMenu to be i - integer, because it is. When i run the code below, it gives me:

Fatal error: Call to a member function bind_param() on a non-object in C:\Users\joonas\Desktop\Le Kerouacoot\adminemove.php on line 44

Code(PHP):

include_once('../php/connDbPrepared.php');
mysqli_set_charset($mysqli, 'utf8');
//Anti mysql injection precautions
$menu = mysqli_real_escape_string($mysqli, $menu);
$sql = "REMOVE FROM menu WHERE fMenu = ?";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("i", $menu);
if($stmt->execute())
{
    $stmt->close();
    echo '
    <script type="text/javascript">
    window.location.replace("../admin/admintable.php?page=main&message=removeSuccessMenu");
    </script>
    ';
}
else
{
    echo '
    <script type="text/javascript">
    $(document).ready(function()
    {
        $("#screenCover").slideToggle("slow");
        $("#closePopup").click(function()
        {
            $("#screenCover").slideToggle("slow");
            setTimeout(resetPage, 600);
        });
});
function resetPage()
{
    window.location.replace("../admin/admintable.php?page=main");
}
</script>
<div id="screenCover" style="display:none;">
<div id="popup">
<div id="closePopupMain">
<p id="closePopup"><a href="#">X</a></p>
</div>
<p id="failure">Le menu n\'a pas éte enlevée! Cause: Erreur '.mysqli_errno($mysqli).": ".mysqli_error($mysqli).'</p>
</div>
</div>';
}
  • 写回答

2条回答 默认 最新

  • dsgm5631 2015-07-09 17:13
    关注

    There is no REMOVE keyword in mysql, use DELETE :

    Delete from menu where fmenu = ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上