你通过直接在数据库中执行你的sql查询语句,看看又没有问题,再打开数据库看看有没有数据,如果有说明你在查找时的变量名错,或者其它的错误

解决方案 »

  1.   

    $str = "'".implode("','",$names)."'";
    if($str=="''") die('计划文件已存在或者没有新条目要添加!');
    require ("config.php");
    $sql="select max(planid) maxid from distributeprogram";
    @$result=mysql_query($sql);
    ($rs=mysql_fetch_object($result)){
         $startId = $rs->planid+1;
    }
    if($startId==0) $startId = 1;
    $sql="select * from distributeprogram where programpath in ($str)";
    @$result=mysql_query($sql);
    while($rs=mysql_fetch_object($result)){
         $tmp[] = "('$startId','".$rs->title."')";
         $statrId++;
    }
    require ("config.php");
    $query = "insert into distributeprogram (planid,programpath) values ";
    if(!is_array($tmp)) die('数据库查找失败');
      

  2.   

    <?
    require ("config.php");
    $names = $addname;foreach($names as $key=>$name){
    $sql="select programpath from distributeprogram where programpath='$name'";
    if(mysql_num_rows(mysql_query($sql))>=1) 
    unset($names[$key]);
    }
    $str = "'".implode("','",$names)."'";
    if($str=="''") die('计划文件已存在或者没有新条目要添加!');
    require ("config.php");
    $sql="select max(planid) maxid from distributeprogram";
    @$result=mysql_query($sql);
    while($rs=mysql_fetch_object($result)){
         $startId = $rs->planid+1;
    }
    if($startId==0) $startId = 1;
    $sql="select * from distributeprogram where programpath in ($str)";
    @$result=mysql_query($sql);
    while($rs=mysql_fetch_object($result)){
         $tmp[] = "('$startId','".$rs->title."')";
         $statrId++;
    }
    require ("config.php");
    $query = "insert into distributeprogram (planid,programpath) values ";
    if(!is_array($tmp)) die('数据库查找失败');
    $query .= implode(',', $tmp);
    @$result=mysql_query($query);
    if ($result)
       echo "<font color=red>恭喜您!成功添加记录!</font>";
    else
       echo "<meta http-equiv='refresh' content='2; url=add.php'><font color=red>添加失败!系统正在返回,请稍候...</font>";
    ?>