警告:oci_execute(): ORA-01400: 无法插入空值


Warning: oci_execute(): ORA-01400: cannot insert NULL value

我是php和oracle的新手,我正在尝试将数据从form插入数据库,但发生了以下错误。

警告:oci_execute(): ORA-01400:无法将 NULL 插入 ("OE"."CUSTOMERS"."CUST_LAST_NAME") 在第 39 行的 C:''wamp''www''PhpProject1'ewentries.php

帮助我如何将数据插入数据库。代码是:

<?php
require_once('./dbinfo.inc.php');
session_start();

echo <<<EOD
  <body style="font-family: Arial, sans-serif;">
  <form action="newentries.php" method="POST">
    <p>First Name: <input type="text" name="firstname"></p>
   <p>Last Name:<input type="text" name="lastname"</p>
    <p>CustomerId: <input type = "text" name = "cust_id"></p>
    <p>Email ID: <input type = "text" name = "cust_email"></p>
    <input type="submit" value="Submit">
  </form>
  </body>
EOD;
if(!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_POST['cust_id']) && !empty($_POST['cust_email']))
{
    $c = oci_pconnect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
    $fname = $_POST['firstname'];
    $lname = $_POST['lastname'];
$id = $_POST['cust_id'];
    $email = $_POST['cust_email'];
    $stid = oci_parse($c, "INSERT INTO CUSTOMERS(CUSTOMER_ID,CUST_FIRST_NAME,CUST_LAST_NAME,CUST_EMAIL) VALUES(:id_bv,:fname_bv,:lname_bv,:email_bv)");
    oci_bind_by_name($stid, ':fname_bv', $fname);
  oci_bind_by_name($stid, ':lname_bv', $lname);
    oci_bind_by_name($stid, ':id_bv', $id);
    oci_bind_by_name($stid, ':email_bv', $email);
    oci_execute($stid);
}   
else
{
    echo 'error';
}

我要在其中输入数据的表

你的代码中有一个简单的拼写错误:

$flname = $_POST['lastname'];
...
oci_bind_by_name($stid, ':lname_bv', $lname);