代码是这样写的:
每次页面提示的错误出现在类成员函数中的 $myrow=mysql_fetch_array($result);
提示说结果集$result无效
凡是调用这个函数的地方就会出错
<?
class flows{                     //建立一个流程类  var $flow_name;               //流程名称
  var $flow_type;               //流程种类
  var $attachment;              //附件
  var $run_id;                  //文件标识
  var $run_name;                //文号
  var $flow_prcs;               //流程步骤
  var $flow_state;              //流程状态
  var $prcs_id=1;              //流程步骤序号
  var $state=1;                 //操作状态参数
  var $flow_id;
  var $date;
  var $next_action=2;           //下一个操作
  var $work_state=1;           //判断工作是否完成  
//-------------------------------------------------------------------------------------------
  
   function flows($myrow)                     
   {
        $this->flow_name=$myrow["flowname"];
$this->flow_type=$myrow["flowtype"];
$this->attachment=$myrow["attachment"];
$this->flow_id=$myrow["flowid"];
$this->run_id=$myrow["runid"];
$this->run_name=$myrow["runname"];
$this->flow_prcs=$myrow["flowprcs"];
$this->flow_state=$myrow["flowstate"];
$this->date=$myrow["date"];

   $sql="SELECT flowid FROM flowtp WHERE flowname=$this->flow_name";
   $result=mysql_query($sql);
   $myrow=mysql_fetch_array($result);
   $this->flow_id=$myrow["flowid"];
           $sql="SELECT steptable stepnum FROM flowtp WHERE flow_id=$FLOW_ID";
           $result=mysql_query($sql);
           $myrow=mysql_fetch_array($result);
           $PRCS_MAX=$myrow["stepnum"];
   $sql="SELECT  stepid FROM $myrow[0] WHERE stepid=$this->flow_prcs";
   $result=mysql_query($sql);
   $myrow=mysql_fetch_row($result);
   $this->prcs_id=$mysql["prcsid"];
           if($PRCS_MAX=$this->prcs_id) 
             $this->work_state=2;    }
//-------------------------------------------------------------------------------------------    function judge($RUN_ID)
   {
     if($this->run_id==RUN_ID)
   return 1;
 else
   return 0;
}

//------------------------------------------------------------------------------------------      function set_action($action)                            //设定下一步操作
   {
 $this->next_action=$action;
    }

//------------------------------------------------------------------------------------------
    
   function printable($tag=0)                                    //打印表格
    {
      if(!$this->work_state=3)
  
     {
  echo "<tr class=\"TableData\">";
  printf("<td align=\"center\">%s</td>",$this->flow_name);
  printf("<td align=\"center\">%s</td>",$this->flow_type);
          printf("<td align=\"center\">%s</td>",$this->attachment);
          printf("<td align=\"center\">%s</td>",$this->run_name);
          printf("<td align=\"center\">%s</td>",$this->flow_prcs);
          printf("<td align=\"center\" nowrap >%s</td>",$this->flow_state);

                                  
      if($this->state>5|| $this->state<1)
        echo("flowstate error!");
      if($this->next_action>6 || $this->next_action<1)
        echo("no such action!");

       //判断行为参数是否合法
   
      switch ($this->state)
      {
        case 1:
    {
        if($this->next_action==2)
    {
      if($this->work_state==0)
        $this->state=2;
      else if($this->work_state==1)
        $this->state=4;
    }
        break;
    }
        case 2:
    {
        if($this->next_action==3 || $this->next_action==4 || $this->next_ction==7&&$this->work_state!=2)
        {
                  $this->work_state=2;
                          $this->state=5;
                 }
    else if($this->next_action==5)
      $this->state=3;  
    break;
    }
        case 3:
    {
        if($this->next_action==6)
    {
      if($this->work_state==0)
        $this->state=2;
      else if($this->work_state==1)
        $this->state=4;
    }
    break;
}
        case 4:
    {
        if($this->next_action==3 || $this->next_action==4 || $this->next_ction==7&&$this->work_state!=2)
      {
        $this->work_state=2;
        $this->state=5;
       }
    else if($this->next_action==5)
      $this->state=3;  
    break;
    }
    
    case 5:
    {
        if($this->work_state==1)
     $this->state=4;
     break;
     }
       }
   //根据一个自动机设置行为参数
       
                switch ($this->state)
      {
        case 1:
    {         echo "<td align=\"center\">" ;
       printf("<a href=\"print.php?RUN_ID=%s&FLOW_ID=%s \" target=\"_blank\">浏览/打印</a>&nbsp;",$this->run_id,$this->flow_id); 
                printf("<a href=\"input_form.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s\">接收/办理</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
                printf("<a href=\"others_free.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s>委托代办人</a>&nbsp;",$this->run_id,$this->flow_id);  
                printf("<a href=\"javascript:delete_run(%s);\">删除</a>",$RUN_ID);
    echo "</td>";
    echo "</tr>";
    break;
     } 
        case 2:
    {
        echo "<td align=\"center\">" ;
        printf("<a href=\"print.php?RUN_ID=%s&FLOW_ID=%s\" target=\"_blank\">浏览/打印</a>&nbsp;",$this->run_id,$this->flow_id); 
                printf("<a href=\"input_form.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s\">接收/办理</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
                printf("<a href=\"others_free.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s>委托代办人</a>&nbsp;",$this->run_id,$this->flow_id); 
                if($this->flow_type=="自由步骤流程")
      printf("<a href=\"turn_next_free.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s\">办结/转交</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
    else if($this->flow_type=="固定步骤流程")
       printf("<a href=\"turn_next_free.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s\">办结/转交</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
                printf("<a href=\"javascript:delete_run(%s);\">删除</a>",$this->run_id);
    echo "</td>";
    echo "</tr>";
    break;
     } 
        case 3:
    {
        echo "<td align=\"center\">" ;
        printf("<a href=\"print.php?RUN_ID=%s&FLOW_ID=%s\" target=\"_blank\">浏览/打印</a>&nbsp;",$$this->run_id,$this->flow_id); 
                printf("<a href=\"javascrip:call_back(%s,%s);\">收回</a>",$this->run_id,$this->prcs_id);
            printf("<a href=\"javascript:delete_run(%s);\">删除</a>",$this->run_id);
    echo "</td>";
    echo "</tr>";
    break;
     }
        case 4:
        {
        echo "<td align=\"center\">" ;
        printf("<a href=\"print.php?RUN_ID=%s&FLOW_ID=%s\" target=\"_blank\">浏览/打印</a>&nbsp;",$this->run_id,$this->flow_id); 
                printf("<a href=\"input_form.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s\">接收/办理</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
                printf("<a href=\"others_free.php?RUN_ID=%s&FLOW_ID=%s&PRCS_ID=%s>委托代办人</a>&nbsp;",$this->run_id,$this->flow_id); 
                printf("<a href=\"javascript:stop_run(%s,%s,%s);>终止</a>&nbsp;",$this->run_id,$this->flow_id,$this->prcs_id); 
                printf("<a href=\"javascript:delete_run(%s);\">删除</a>",$this->run_id);
     echo "</td>";
     echo "</tr>";
    break;
    }
  } 
   
  }
 }
    //根据行为参数打印操作

//浏览打印=1
//接收办理=2
//委托代办人=3
//删除=4
//办结转交=5
//收回=6
//中止=7

}
?>

解决方案 »

  1.   

    <html>
    <head>
    <title>工作流</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" type="text/css" href="/inc/style.css"><script Language=JavaScript>
    window.setTimeout('this.location.reload();',180000);
    </script><script>
    function delete_run(RUN_ID)
    {
      msg='确认要删除该项工作流程么?';
      if(window.confirm(msg))
      {
        url="delete.php?RUN_ID="+RUN_ID;
        location=url;
      }
    }function stop_run(RUN_ID,FLOW_ID,PRCS_ID)
    {
      msg='确认要终止该项工作流程么?';
      if(window.confirm(msg))
      {
        url="stop.php?RUN_ID="+RUN_ID+"&FLOW_ID="+FLOW_ID+"&PRCS_ID="+PRCS_ID;
        location=url;
      }
    }function call_back(RUN_ID,PRCS_ID)
    {
      msg='确认要收回该步骤重新执行么?';
      if(window.confirm(msg))
      {
        url="call_back.php?RUN_ID="+RUN_ID+"&PRCS_ID="+PRCS_ID;
        location=url;
      }
    }</script>
    </head><body class="bodycolor" topmargin="5">
    <table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
      <tr>
        <td class="Big"><img src="/images/notify_new.gif"><b><font color="#FFFFFF"> 新建工作</font></b><br>
        </td>
      </tr>
    </table><div align="center">
    <input type="button"  value="新建工作" class="BigButton" onClick="location='edit.php'" title="新建工作"   name="newflow">
    </div><br><table width="95%" border="0" cellspacing="0" cellpadding="0" height="3">
     <tr>
       <td background="/images/dian1.gif" width="100%"></td>
     </tr>
    </table><table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
      <tr>
        <td class="Big"><img src="/images/notify_open.gif"><b><font color="#FFFFFF"> 待办工作</font></b><br>
        </td>
      </tr>
    </table>
    <br>  
    <table border="0" cellspacing="1" width="101%" class="small" bgcolor="#0099FF" cellpadding="3">
      <tr class="TableHeader">
          <td width="14%" align="center" nowrap>流程名称</td>
          
        <td width="13%" align="center" nowrap bgcolor="#0099FF">流程类型</td>
          <td width="7%" align="center" nowrap>附件</td>
          <td width="7%" align="center" nowrap>文号</td>
          <td width="11%" align="center" nowrap>步骤</td>
          <td width="9%" align="center" nowrap>状态</td>
          <td width="39%" align="center" nowrap>操作</td>
        </tr>
    <?
    $USER_ID=1;
    require "mysql.php";
    if(!isset($newflow)&&!isset($submit))
     {     $result=mysql_query("SELECT * FROM workflow info WHERE userid=1");
         if($result=="")
         { 
             echo("现在没有工作:)");
      }
          else   
         {
      
          $i=0;
              while($myrow=mysql_fetch_array($result) )
             {             if(mysql_errno())
                 {
                      die("<br>".mysql_errno().":".mysql_errno()."<br>");
                 }
     if(!isset($flow[$i]))                                  //判断对方是否已经赋值
     {
                                 $flow[$i]= new flows($myrow);                      //建立流程类
         if($flow[$i]->judge($RUN_ID) && $ACTION!="")
                 {
           $flow[$i]->setaction($ACTION);                   //判断上一个操作是什么  
                           $flow[$i]->printable();                          //打印表格
         }
      }                                      
             }
          }
     }
    ?> </table>
    <br>
    <br>
    <table width="95%" border="0" cellspacing="0" cellpadding="0" height="3">
     <tr>
       <td background="/images/dian1.gif" width="100%"></td>
     </tr>
    </table><table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
      <tr>
        <td class="Big"><img src="/images/menu/infofind.gif" WIDTH="22" HEIGHT="20"><b><font color="#FFFFFF"> 工作查询</font></b><br>
        </td>
      </tr>
    </table>
    <br><table border="0" width="450" cellpadding="3" cellspacing="1" align="center" bgcolor="#0099FF" class="small">
      <form action="search.php" name="form1">
        <tr>
          <td nowrap class="TableData">流程名称:</td>
          <td class="TableData">
            <select name="FLOW_ID" class="BigSelect">
    <?
      $sql="SELECT * FROM flowtp";
      $result=mysql_query($sql);
      while($myrow=mysql_fetch_array($result))
            printf("<option value=\"%s\">%s</option>",$myrow["flow_id"],$myrow["flow_name"]);
      mysql_close($db);
    ?>
            </select>
          </td>
        </tr>
        <tr>
          <td nowrap class="TableData">工作流状态:</td>
          <td class="TableData">
            <select name="WORK_STATE" class="BigSelect">
              <option value="2">已完成</option>
              <option value="0">执行中</option>
            </select>
          </td>
        </tr>
        <tr>
          <td nowrap class="TableData">文号:</td>
          <td class="TableData">
            <input type="text" name="RUN_NAME" size="30" maxlength="100" class="BigInput">
          </td>
        </tr>
        <tr align="center" class="TableControl">
          <td colspan="2" nowrap>
            <input type='hidden' value="" name="RUN_ID">
            <input type="submit"  value="查询" class="BigButton" name="submit">&nbsp;&nbsp;
          </td>
        </tr>
      </form>
    </table></body>
    </html>
      

  2.   

    应该不是类的错误,是你的类的定义有错。
    你可以先把sql语句打印出来看看。
      

  3.   

    肯定是类定义错了
    但是不知道错在哪里不用打印sql因为肯定是能不正确访问数据库的
    sql是在类成员函数里面,当然不可能正确的查询
      

  4.   

    $sql="SELECT steptable stepnum FROM flowtp WHERE flow_id=$FLOW_ID";
    中$FLOW_ID未定义
      

  5.   

    错误不在这里:(那个变量是放在session中的
      

  6.   

    放在session中就更不对了,必须声明为全局的。你可以输出来看看