简体   繁体   中英

Using HTML form to update Oracle Database - Database Not Updating

I am attempting to create a form where an admin can update a webpage's data. I am taking the form's $_POST variables and sending them to the handler (in this case, UpdateInfo_SA.php). From there I am trying to send it to the database (see snippet 1). There is no error, in fact the page is blank (which is expected, given the current code). However, the table does not update.

Info:

Table Name: LOGISTICS_SLIDESHOW

Updating OH_RECORDABLE_ENERGY to any value (just to test to see if this works) where LOGISTICS_UPDATEID=0 (this represents the first column of the table).

Snippet 1 (Form Handler - UpdateInfo.php):

<?php
    require_once("mcl_Oci.php");
    $objConnect = oci_connect("user", "pass", "(description=(address=(protocol=tcp)(host=HOST)(port=1533))(connect_data=(service_name=SID)))")
    $strSQL = "UPDATE INTOXDM.LOGISTICS_SLIDESHOW ";  
    $strSQL .="SET OH_RECORDABLE_ENERGY = '6'";  
    $strSQL .="WHERE LOGISTICS_UPDATEID= 0 ";
    $objParse = oci_parse($objConnect, $strSQL);  
    $objExecute = oci_execute($objParse, OCI_DEFAULT);?>  

Snippet 2 (Form - SA_Update.php):

<?php

    $objConnect = oci_connect("user", "pass", "(description=(address=(protocol=tcp)(host=HOST)(port=1533))(connect_data=(service_name=SID)))");

?>

<div align="center">
    <span style="font-size:60px";>
        <u>Update Page<br></u>
        Schedule Adherence: OH Contractors<br>
    </span>

<form method="post" action="UpdateInfo_SA.php">
    <span style="font-size:30px;">
        <u>Total YTD:<input type="number" name="SA_ytd_total" value="%"><br>
        Total MTD:<input type="number" name="SA_mtd_total" value="%"><br>
        Energy YTD: <input type="number" name="SA_ytd_energy" value="total"><br>
        Energy MTD: <input type="number" name="SA_mtd_energy" value="total"><br>
        Hydraker YTD: <input type="number" name="SA_ytd_hydraker" value="total"><br>
        Hydraker MTD: <input type="number" name="SA_mtd_hydraker" value="total"><br>
        NG Gilbert YTD: <input type="number" name="SA_ytd_gilbert" value="total"><br>
        NG Gilbert MTD: <input type="number" name="SA_mtd_gilbert" value="total"><br></u>
        <input type="submit" value="Submit">
</form>

As you can tell, the server is using php's to communicate with itself and the database. Thanks for any help you can give, it is very appreciated!!

Do you commit the transaction in your php, where open up the connection and update ?

Unless autocommit is turned ON or you commit ,the updated data is not available to the rest of world

EDIT: http://www.php.net//manual/en/function.oci-execute.php

The above link refers to the auto commit options available. Default is NO auto commit.. So all updates are rollbacked when the session is disconnected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM