0

This is the table when I put value it is not inserted when i run the .php file output is data was not inserted... i cant find the error .what to do? as i am new in php somebody plz help

The table:

create table Employee(
E_ID number(10) primary key,
E_First_Name varchar2(10),
E_Last_Name varchar2(10),
E_Gender varchar2(6),
E_address varchar2(20),
E_phone_No number(10),
E_category varchar2(10),
EMP_salary number(20),
work_hour varchar2(20),
Date_Of_Join date
);

The php code page:

<?php
    $conn=oci_connect("system","123","localhost/orcl");
    ob_start();
    $current_file=$_SERVER['SCRIPT_NAME'];
    $massage= "";
    if(isset($_POST['E_ID'])&&isset($_POST['E_First_Name'])&&
    isset($_POST['E_Last_Name'])&&isset($_POST['E_Gender'])&&
    isset($_POST['E_address'])&&isset($_POST['E_phone_No'])&&
    isset($_POST['E_category'])&&isset($_POST['EMP_salary'])&&
    isset($_POST['work_hour'])&&isset($_POST['Date_Of_Join']))
    {
        $E_ID = $_POST['E_ID'];
        $E_First_Name= $_POST['E_First_Name'];
        $E_Last_Name = $_POST['E_Last_Name'];
        $E_Gender = $_POST['E_Gender'];
        $E_address = $_POST['E_address'];
        $E_phone_No = $_POST['E_phone_No'];
        $E_category = $_POST['E_category'];
        $EMP_salary = $_POST['EMP_salary'];
                                       $work_hour =$_POST['work_hour'];
                                       $Date_Of_Join=$_POST['Date_Of_Join'];

        if(!empty($E_ID)&&!empty($E_First_Name)&&!empty($E_Last_Name)&&
        !empty($E_Gender)&&!empty($E_address)&&!empty($E_phone_No)&&
        !empty($E_category)&&!empty($EMP_salary)&&!empty( $work_hour)&&!empty($Date_Of_Join))
        {

                $sql = "insert into Employee values('".$E_ID."','".$E_First_Name."','".$E_Last_Name."','".
                $E_Gender."','".$E_address."',".$E_phone_No.",".$E_category .",".$EMP_salary.",".  $work_hour.",".$Date_Of_Join.")";
                //echo $sql.'<br>';
                $stid = oci_parse($conn,$sql);
                $r = @oci_execute($stid);
                if($r)
                {
                    echo ' data is inserted...<br>';
                }
                else
                {
                    echo 'data was not inserted...<br>';
                }

        }
        else
        {
            $massage = "please fill up all the form correctly<br>";
        }
    }

?>
<html>
<head>
<title>Create FoodItem Table</title>
<style>
body
{
background:orange;
}
</style>
<head>
<body>
fill all the forms for inserting data:<br><br>
<?php echo $massage;?>
<hr color="green">
<form action="<?php echo $current_file;?>" method="POST">

    E_ID:<br> <input type="number" name="E_ID" autofocus><br><br>
    E_First_Name:<br> <input type="text" name ="E_First_Name" ><br><br>
    E_Last_Name:<br> <input type="text" name="E_Last_Name" ><br><br>
    E_Gender:<br> <input type="text" name="E_Gender" ><br><br>
    E_address:<br> <input type="text" name ="E_address"><br><br>
    E_phone_No:<br> <input type= "number" name="E_phone_No" ><br><br>
    E_category:<br><input type="text" name="E_category"><br><br>
    EMP_salary:<br><input type="number" name="EMP_salary" ><br><br>
    work_hour:<br><input type="text"name="work_hour"><br><br>
                  Date_Of_Join:<br><input type="text"name="Date_Of_Join"><br><br>
    <input type ="submit" value="Create employee "><br><br>
    <a href="index..php">Home</a>

</form>
</body>
</html>
1
  • 1
    If it's because of my answer below, do click the White checkmark next to my answer till it turns Green. That is how the question is closed and considered answered and provided the solution; and Welcome to StackOverflow. @user3440295 Commented Mar 20, 2014 at 7:35

1 Answer 1

1

This line is missing single quotes around some of the values:

('".$E_ID."','".$E_First_Name."','".$E_Last_Name."','".$E_Gender."','".$E_address."', 
".$E_phone_No.", ".$E_category .",".$EMP_salary.",".  $work_hour.",".$Date_Of_Join.")

Change it to:

('".$E_ID."','".$E_First_Name."','".$E_Last_Name."','". $E_Gender."','".$E_address."', 
'".$E_phone_No."','".$E_category ."','".$EMP_salary."','".$work_hour."','".$Date_Of_Join."')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.