php代码出错,而不是更新日期表

时间:2013-02-08 09:52:22

标签: php mysql

我有unsub.php代码:

<?php 
include("config.inc.php");
$id=$_REQUEST['id'];
$time=$_REQUEST['t'];
$cid=0;
if(isset($_REQUEST['cid']))
$cid=$_REQUEST['cid']

if($cid==0)
mysql_query("update email_advt set unsubstatus=1 where id=$id AND time=$time");
else
{
if($mysql->total(email_advt","id=$id AND time=$time")>0)
mysql_query("delete from ea_em_n_cat where eid=$id AND cid=$cid");
}

?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title> Unsubscribe Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Your email has been successfully unsubscribed from our mailing list. <br>
</body>
</html>

这个表:

CREATE TABLE IF NOT EXISTS `email_advt` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(250) NOT NULL DEFAULT '',
  `unsubstatus` int(11) NOT NULL DEFAULT '0',
  `time` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

CREATE TABLE IF NOT EXISTS `ea_em_n_cat` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `eid` int(11) NOT NULL DEFAULT '0',
  `cid` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;

当访问unsub.php?id = 1&amp; t = 1360306174&amp; cid = 0时 未显示您的电子邮件已成功取消订阅我们的邮件列表 怎么了 ?访问unsub.php时,unsubstatus未设置为1?id = 1&amp; t = 1360306174&amp; cid = 0

3 个答案:

答案 0 :(得分:0)

使用此查询,您错过了反引号`

mysql_query("update email_advt set `unsubstatus`=1 where `id`=$id AND `time`=$time");

答案 1 :(得分:0)

我认为你有错误:

if($mysql->total(email_advt","id=$id AND time=$time")>0)

if($mysql->total("email_advt"," id=$id AND time=$time")>0)

虽然我不确定你想要得到什么或total()方法的论据。

答案 2 :(得分:0)

如果您使用内置函数作为列名,则需要将其用重音符号括起来。即在您的查询中,您使用的是time列,这是MySQL中的内置函数。