我正在使用此代码使用 php 和数据插入将数据插入到 oracle 数据库中,但在 oracle 数据库中我使用的不是空值。但是当我刷新页面时出现错误:
未定义索引:operator_id in
代码
<?php
{
$ora_conn = oci_connect('system','oracle','//localhost/XE');
if(!$ora_conn)
{
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else
{
//print "You are connected to the database!<br/>";
}
if (isset($_POST['Submit']))
{
$optid = $_POST['operator_id'];
$optdec = $_POST['operater_description'];
$empid = $_POST['employee_id'];
$empmail = $_POST['employee_emailid'];
}
$query = "SELECT * FROM optr_add WHERE OPERATOR_ID=
'".$_POST['operator_id']."' OR
employee_emailid = '".$_POST['employee_emailid']."'
OR employee_id = '".$_POST['employee_id']."'";
$s=oci_parse($ora_conn, $query);
oci_execute ($s,OCI_DEFAULT);
$objResult = oci_fetch_array($s);
if($objResult)
{
echo "<script>alert('Operator ID already exist')</script>";
}
else
{
$query = 'INSERT INTO optr_add
(operator_id , operater_description ,employee_id,employee_emailid)**<<---here**
VALUES (:operator_id ,:operater_description,:employee_id,:employee_emailid)';
$s=oci_parse($ora_conn, $query);
oci_bind_by_name($s, ':operator_id', $optid );
oci_bind_by_name($s, ':operater_description', $optdec);
oci_bind_by_name($s, ':employee_id', $empid);
oci_bind_by_name($s, 'employee_emailid', $empmail );
if (isset($_POST['Submit']))
$objExecute=oci_execute($s);
if (isset($_POST['Submit']))
{
if (!isset($optid) || empty($optid))
{
//header( "refresh:1110;url=Define_Organization.php" );
echo"<script>alert('Submit Successfully')</script>";
exit();
echo"<script>alert('Please enter your data')</script>";
exit();
}
}
oci_free_statement($s);
oci_close($ora_conn);
}
}
?>