使用php搜索oracle数据库不工作
任何人都可以帮助我。。。这里有4个字段,一个是oprid、oprname、empid,另一个字段是email。我想通过oprid、oprname、empid或电子邮件进行搜索,但不起作用使用php搜索oracle数据库不工作,php,oracle,Php,Oracle,任何人都可以帮助我。。。这里有4个字段,一个是oprid、oprname、empid,另一个字段是email。我想通过oprid、oprname、empid或电子邮件进行搜索,但不起作用 Operator ID Operator Name Person ID Email ID 警告:oci_execute()要求参数1为资源,在第55行的C:\xampp\htdocs\result\elishdb\muti1.php中为空 警告:oci_fetch_array()希望参数1是资
Operator ID Operator Name Person ID Email ID
警告:oci_execute()要求参数1为资源,在第55行的C:\xampp\htdocs\result\elishdb\muti1.php中为空
警告:oci_fetch_array()希望参数1是资源,在第56行的C:\xampp\htdocs\result\elishdb\muti1.php中给出空值
<?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);
}
}
?>
谢谢你的问题是语法错误。定义查询变量时,select之后有一个额外的空格
而不是:
$query ="SELECT * FROM
尝试:
您必须在sql查询之外定义$objParse
:
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
}
}
变量objParse
未定义,在何处声明?如何定义objParse以及在此编码中定义在何处。代码已更新…现在检查我的代码错误…Oracle对空格不可知变量objParse未定义此问题解决感谢…但此处2错误获取…警告:oci_execute()预期参数1为资源,第56行C:\xampp\htdocs\result\elishdb\muti1.php中给出的null警告:oci\u fetch\u array()期望参数1是资源,第57行C:\xampp\htdocs\result\elishdb\muti1.php中给出的null
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
}
}