if ($total>0){
  $sql="SELECT * from duoduo_myquanlog where TO_DAYS(qu_date)>=TO_DAYS(now()) and qu_username='".$_SESSION['ddusername']."'";
  $rs = mysql_query($sql);
  $total1 = mysql_num_rows($rs);
  if ($total1<1){
     $sql="select * from ".$BIAOTOU."youhuiquan,duoduo_mall where duoduo_youhuiquan.qu_mallid=duoduo_mall.id and qu_id='".$mall_id."'";//获取优惠券信息
     $query=mysql_query($sql);
     $mall=mysql_fetch_array($query);
     $quan_str='您好,你的优惠券发放成功!<br>优惠券卡号是:'.$mall('qu_num');
     if($mall('qu_pwd')!=''){
        $quan_str=$quan_str.'<br>密码:'.$mall('qu_pwd');
      }
     $quan_str=$quan_str.'<br>请在:'.$mall('qu_daoqi').'前使用,否则优惠券会失效!同时请一定单击下面的链接到商城购物:<br><a href=mall.php?id=';
     $quan_str=$quan_str.$mall('id').'>马上拿优惠券去'.$mall('name').'购物</a>';
     $isfafang=1;
 $insert="UPDATE ".$BIAOTOU."youhuiquan set qu_isuse=1 where qu_id=".$mall_id;
     mysql_query($insert);
     echo $quan_str;
    }
else
....后面的没有出错,就是进入上面的条件时才出错的

解决方案 »

  1.   

    $sql="select * from ".$BIAOTOU.",youhuiquan,duoduo_mall where duoduo_youhuiquan.qu_mallid=duoduo_mall.id and qu_id='".$mall_id."'
    这个语句打出来看看,这个语句一看就有问题
      

  2.   

    我是一个新手,第一次用PHP,以前用ASP的,
    if ($total>0){
      $sql="SELECT * from duoduo_myquanlog where TO_DAYS(qu_date)>=TO_DAYS(now()) and qu_username='".$_SESSION['ddusername']."'";
      $rs = mysql_query($sql);
      $total1 = mysql_num_rows($rs);
      if ($total1<1){
      $sql="select * from ".$BIAOTOU."youhuiquan,duoduo_mall where duoduo_youhuiquan.qu_mallid=duoduo_mall.id and qu_id='".$mall_id."'";//获取优惠券信息
      $query=mysql_query($sql);
      $mall=mysql_fetch_array($query);
      $quan_str='您好,你的优惠券发放成功!<br>优惠券卡号是:'.$mall('qu_num');
      if($mall('qu_pwd')!=''){
      $quan_str=$quan_str.'<br>密码:'.$mall('qu_pwd');
      }
      $quan_str=$quan_str.'<br>请在:'.$mall('qu_daoqi').'前使用,否则优惠券会失效!同时请一定单击下面的链接到商城购物:<br><a href=mall.php?id=';
      $quan_str=$quan_str.$mall('id').'>马上拿优惠券去'.$mall('name').'购物</a>';
      $isfafang=1;
    $insert="UPDATE ".$BIAOTOU."youhuiquan set qu_isuse=1 where qu_id=".$mall_id;
      mysql_query($insert);
      echo $quan_str;
      }
    else
      

  3.   

    $sql="select * from ".$BIAOTOU."youhuiquan,duoduo_mall where duoduo_youhuiquan.qu_mallid=duoduo_mall.id and qu_id='".$mall_id."'";echo $sql;
      

  4.   

    打出来了,放在mysql workbench可以正常运行
      

  5.   

    select * from duoduo_youhuiquan,duoduo_mall where duoduo_youhuiquan.qu_mallid=duoduo_mall.id and qu_id=2
      

  6.   

    回了的,$total是从数据库中读取出来的,这个变量变出来了,证明连上去了
      

  7.   

    那还是看看有什么错误输出吧:
    if ($total>0){
      error_reporting(E_ALL); //加上这一句试试
      ...
      

  8.   

    执行SQL的语句也要输出错误:
    $query=mysql_query($sql);
    改为:
    if (!$query = mysql_query($sql)) die(mysql_error());mysql_query($insert);
    改为:
    if (!mysql_query($insert)) die(mysql_error());
      

  9.   

    问题找到了,访问数组元素是用[]的,我用了()所以错了,但是最后还有一个问题
    $insert="UPDATE ".$BIAOTOU."youhuiquan set qu_isuse=1,qu_usedata=now() where qu_id=".$mall_id;
    mysql_query($insert);
    这个语句是不是没有执行,好像没有更新一样
      

  10.   

    mysql_error()看看,如果不报错的话就是执行了。。