gpt4 book ai didi

php - Isset表达式错误

转载 作者:IT王子 更新时间:2023-10-29 00:07:25 24 4
gpt4 key购买 nike

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

我有删除代码的问题,由于错误,它似乎不起作用:

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']))) {

删除类别.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>

删除.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']))
^---

关于php - Isset表达式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23205968/

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