$result2 = $DB->query( $SqlStr1 );
if(!empty($result2))这两句上可能有问题.

解决方案 »

  1.   

    if(!empty($result2))这一句有问题。
      

  2.   

    if(!$DB->query( $SqlStr1 ))是这样么?
      

  3.   

    $SqlStr1 = "Select * From table where name = ".$name." and sid=".$id;
    这个sql指令错了!
    所以必然导致$result2 为空,从而执行插入操作...name = ".$name." ...
    单引号呢?你都知道在insert指令中加上,这里呢?
      

  4.   

    加了单引号就不会执行insert语句了
      

  5.   

    $DB->query返回的是什么东西?是resource,array还是boolean?
    这都没搞清楚,就用empty判断了有什么用?
    如果是mysql_query只要sql语句正确,返回的都是resource id,哪来的empty?
    要判断有没有数据还要调用myql_fetch_array()才能知道
      

  6.   

    问题解决,一是单引号问题,二是if(!empty($result2)),谢谢大家,分不多,大家分吧
      

  7.   

    错误:
    1、加单引号
    $SqlStr1 = "Select * From table where name = ".$name." and sid=".$id;
    改为$SqlStr1 = "Select * From table where name = '".$name."' and sid='".$id."'";2、判断更改
    if(!empty($result2))
    改为 if($DB->num_rows() > 0) //查一下你的DB类中num_rows()对应的是什么