私はphpとデータ挿入を使用してOracleデータベースにデータを挿入するためにこのコードを使用していますが、Oracleデータベースではnull値ではありません.しかし、ページを更新するとエラーが発生します:
未定義のインデックス: operator_id 内
コード
<?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);
}
}
?>