Isset表达式错误 [英] Isset expression error

查看:172
本文介绍了Isset表达式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上已经编码了一个代码,该代码填充了数据库中的类别列表,然后您可以选择要删除的类别.

I have basically coded a code which populates a list of categories from my database then you are able to select which to delete.

我遇到了删除代码的问题,由于该错误,该代码似乎不起作用:

I have the issue with the delete code which does not seem to work due to the error:

Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in F:\xamppnew\htdocs\650032\admin\delete.php on line 6

引起此情况的行是:

if(isset($_POST['delete_id'] && !empty($_POST['delete_id']))) {

deletecategory.php

deletecategory.php

    <h3>
     Delete Category
    </h3>

    <?php $result = mysql_query("SELECT * FROM category"); ?>

<table>
  <?php while($row = mysql_fetch_array($result)) : ?>
  <tr id="<?php echo $row['category_id']; ?>">
    <td><?php echo $row['category_Name']; ?></td>
    <td>
      <button class="del_btn" rel="<?php echo $row['id']; ?>">Delete</button>
    </td>
  </tr>
  <?php endwhile; ?>
</table>

<script>
  $(document).ready(function(){
    $('.del_btn').click(function(){
       var del_id = $(this).attr('rel');
       $.post('delete.php', {delete_id:del_id}, function(data) {
          if(data == 'true') {
            $('#'+del_id).remove();
          } else {
            alert('Could not delete!');
          }
       });
    });
  });
</script>

delete.php

delete.php

<?php
    if(isset($_POST['delete_id'] && !empty($_POST['delete_id']))) {
      $delete_id = mysql_real_escape_string($_POST['delete_id']);
      $result = mysql_query("DELETE FROM category WHERE `id`=".$delete_id);
      if($result !== false) {
        echo 'true';
      }
    }
    ?>

推荐答案

您错过了此):

if(isset($_POST['delete_id']) && !empty($_POST['delete_id']))
                            ^---

这篇关于Isset表达式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆