gpt4 book ai didi

php - PHP代码既不产生结果也不产生错误

转载 作者:行者123 更新时间:2023-11-30 00:06:08 24 4
gpt4 key购买 nike

我有一个服务器脚本,允许用户将任何项目标记为收藏,但我还希望使用另一个脚本,如果需要,用户可以通过该脚本取消收藏同一项目,并且应从收藏列表中删除该项目。对于我喜欢的和不喜欢的代码,我都保留了相同的表。为此,我有一个代码

<?php
require_once('config.php');
$favorite = $_REQUEST['favorite'];
$unfavorite = $_REQUEST['unfavorite'];
$id=$_REQUEST['id'];

$unfavoritedeal=mysql_query("SELECT * FROM favoritedeals where id='".$id."'"); //favoritedeals is the name of the table

if($row=mysql_fetch_array($unfavoritedeal))
{
$favorite=$row['favorite'];
$unfavorite=$row['unfavorite'];
}

$myfavorite=(isset($_REQUEST['favorite'])?$_REQUEST['favorite']:$favorite);
$myunfavorite=(isset($_REQUEST['unfavorite'])?$_REQUEST['unfavorite']:$unfavorite);

$update = mysql_query("update favoritedeals set favorite = '".$myfavorite."', unfavorite = '".$myunfavorite."' where id = '".$id."'");


$posts[0]['message'] = 'favorite list updated';
$selectt = mysql_query("select * from favoritedeals where id = '".$id."'");
$results = mysql_fetch_assoc($selectt);
$posts[0]['detail'] = $results;

if($unfavorite="0" where id='".$id."')
{
$sql="delete from favoritedeals WHERE id='".$id."'";
if(mysql_query($sql))
{
header('Content-type: application/json');
echo json_encode(array('favorite deals'=>'Deal has been updated'));
}
else
{
header('Content-type: application/json');
echo json_encode(array('favorite deals'=>'Deal not updated'));
}


}

$selectt = mysql_query("select * from favoritedeals where id = '".$id."'");
$results = mysql_fetch_assoc($selectt);
$posts[0]['detail'] = $results;
header('Content-type: application/json');
echo json_encode($posts);


?>

当我运行此代码时,既没有显示错误,也没有产生预期的结果。谁能建议我一个合适的代码/解决方案

最佳答案

尝试将此代码放在文件顶部。

error_reporting(-1);


更多详细信息: http://www.php.net/manual/en/function.error-reporting.php

关于php - PHP代码既不产生结果也不产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24531112/

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