0

任何人都可以帮助我...这里有 4 个字段,一个是 oprid、oprname、empid,另一个字段是电子邮件。我想通过 oprid、oprname、empid 或电子邮件进行搜索,但它不起作用,

Operator ID     Operator Name   Person ID   Email ID

警告:oci_execute() 期望参数 1 是资源,在第 55 行的 C:\xampp\htdocs\result\elishdb\muti1.php 中给出 null

警告:oci_fetch_array() 期望参数 1 是资源,在第 56 行的 C:\xampp\htdocs\result\elishdb\muti1.php 中给出 null

   <?php
   {
  include ('connection.php');
  $objParse = null;


  if(isset($_REQUEST['submit'])){

 $optid = '%' . $_POST['OPRID'] . '%';
 $optdec = '%' . $_POST['OPRDEFNDESC']. '%';
 $empid = '%' . $_POST['EMPLID']. '%';
 $empmail = '%' . $_POST['EMAILID']. '%';
  $query ="SELECT * FROM OPERATOR WHERE OPRID LIKE :optid  
 or OPRDEFNDESC LIKE:optdec or EMPLID LIKE :empid
 or EMAILID LIKE :empemail "; 

$objParse = oci_parse ($ora_conn, $query);

 oci_bind_by_name($objParse, ':optid', $optid);
 oci_bind_by_name($objParse, ':optdec', $optdec);
 oci_bind_by_name($objParse, ':empid', $empid);
 oci_bind_by_name($objParse, ':empemail', $empemail);
 }
 ?>

<form action="muti1.php" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="500" border="1" align="center">  
<tr>  
 <th>Operator ID
  <input name="OPRID" type="text" id="OPRID" value="";>  
  <tr>  
 <th>Operator Name
  <input name="OPRDEFNDESC" type="text" id="OPRDEFNDESC" value="";>  
  <tr>  
  <th>Person ID
  <input name="EMPLID" type="text" id="EMPLID" value="";>  
  <tr>  
  <th>Email ID
  <input name="EMAILID" type="text" id="EMAILID" value="";>  
  <input type="submit" value="Search"></th>  
  </tr>  
  </table>  
  </form> 

   <table>
   <tr>
   <td>Operator ID</td>
   <td>Operator Name</td>
   <td>Person ID</td>
   <td>Email ID</td>
   </tr>
   </table>
    <?  

  $success = oci_execute($objParse);
   while($objResult = oci_fetch_array($objParse, OCI_RETURN_NULLS+OCI_ASSOC)) 
   {  
  if ($objParse == null)
  {


 echo "fail";
 }
 else
  {
 ?>  
  <tr>  
 <td><div align="center"><?=$objResult["OPRID"];?></div></td>  
 <td><?=$objResult["OPRDEFNDESC"];?></td>  
 <td><?=$objResult["EMPLID"];?></td>  
 <td><div align="center"><?=$objResult["EMAILID"];?></div></td> 
 <td align="center"><a  href="Optr_Edit.php?OprID=<?=$objResult["OPRID"];?>">Edit</a>  

 </td> 
 </tr>  
  <?  
   }  
    ?>  
 </table>  
  <?  
 oci_free_statement($objParse);
 oci_close($ora_conn); 
   }
   }
  ?>  
4

2 回答 2

0

您必须$objParse在 sql 查询之外定义:

include ('connection.php');
$objParse = null;
if(isset($_REQUEST['submit'])){
    //........
}

// form here

if ($objParse == null) {
    // echo no result for the given query
} else {
    $success = oci_execute($objParse);
    while($objResult = oci_fetch_array($objParse, OCI_RETURN_NULLS+OCI_ASSOC)) 
    { 
        // print results here
    }
}
于 2013-10-14T05:52:50.290 回答
0

谢谢你的问题是语法错误。定义查询变量时选择后有一个额外的空间

代替:

$query ="SELECT  * FROM 

尝试:

$query ="SELECT * FROM 
于 2013-10-14T05:29:52.200 回答