0

I am trying to create an update page which uses a form to update the details in an oracle table. I am getting an undefined index on two of the columns, OCI8 and oracle are fairly new to me so not 100% sure what I am doing.

Here is my code:

<?php
$conn = oci_connect("xxxxx", "xxxxxx", "xxxxxx");if(count($_POST)>0) {
    $query=oci_parse($conn, "UPDATE AUTOMATEDAIVEHICLE SET APPLICATIONID='" . $_POST['APPLICATIONID']."', Application Name='" . $_POST['Application Name']."', TYPEOFVEHICLEID='" . $_POST['TYPEOFVEHICLEID']."', Type Of Vehicle Descripton='" . $_POST["Type Of Vehicle Description"]."'");
    $result=oci_execute($query, OCI_DEFAULT);  
    if($result)  
    {  
        oci_commit($conn);
        echo "Data Updated Successfully !";
    }
    else{
        echo "Error.";
    }
    
}
$query="SELECT * FROM AUTOMATEDAIVEHICLE WHERE VEHICLEID='" . $_GET['VEHICLEID'] . "'";
$result=oci_parse($conn,$query);
oci_execute($result);
$row=oci_fetch_array($result);
?>
<html>
<head>
    <title>Update Type Of Vehicle</title>
</head>
<body>
<form name="frmAWFID" method="post" action="">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div style="padding-bottom:5px;">
<a href="view.php">Index Page</a>
</div>
    Application ID: <br>
    <input type="text" name="APPLICATIONID"  value="<?php echo $row['APPLICATIONID']; ?>">
    <br>
    Application Name: <br>
    <input type="text" name="Application Name"  value="<?php echo $row['Application Name']; ?>">
    <br>
    Type of Vehicle ID: <br>
    <input type="text" name="TYPEOFVEHICLEID"  value="<?php echo $row['TYPEOFVEHICLEID']; ?>">
    <br>
    Type Of Vehicle Description :<br>
    <input type="text" name="Type Of Vehicle Description"  value="<?php echo $row['Type Of Vehicle Description']; ?>">
    <br>
    <input type="submit" name="submit" value="Submit" class="button">

</form>
</body>
</html>

I believe it may be an issue with my sql however I am not completely sure, all of the table and column names are correct.

Any help will be much appreciated.

  • 1
    (Possible) side note: Do not use string interpolation or concatenation to get values into SQL queries. That's error prone and might make your program vulnerable to SQL injection attacks. Use parameterized queries. – sticky bit Mar 17 '21 at 22:17
  • Since you're new to it all, the back half of this free PHP Oracle book https://www.oracle.com/database/technologies/underground-php-oracle-manual.html is still useful to read in addition to the PHP OCI8 manual pages. – Christopher Jones Mar 18 '21 at 21:54

0 Answers0