duanbage2161
duanbage2161
2014-07-09 14:19

当嵌套在if中时,为什么我的代码不会更新或插入到Oracle DB中?

已采纳

I am attempting to create code that takes user input via HTML form, and processes it using if statements (see below).

When I input data and click submit, no errors are reported. However, no data is updated in the oracle DB either. Next I will walk you through my logic, lines will be marked by /* ## */ to make it easier to understand.

So, the user inputs the week they are editing [/ 01 /]. Next is the day of the week they are editing (below / 01 /). These are the two values being used in the "if" statement (see handler) where my problem is.

Line designated / 02 / in handler is checking to see if there are any existing weeks matching that inputted by the user to edit.

Line designated / 03 / in handler beigns the if statement that takes $week, the row which may exist, and either edits or inserts depending on whether or not it is set.

There are 8 columns in this database: WEEK, and all days of the week (MONDAY, TUESDAY...SUNDAY).

Any help is greatly appreciated, TIA!

Form:

    <div align="center">
        <span style="font-size:60px;">
            Day to Day Tree Events - Update Page <br/>
            Be very cautious when editing this page. <br>
            Misformatting can cause data to be deleted or altered incorrectly. <br>
        </span>
    </div>

    <div align="center">
        <form method="post" action="UpdateInfo_Tree.php">
            <span style="font-size:30px;">
                <u>As Of:[mm/dd/yyyy]:<input type="date" name="TREE_updated" value="<?php echo $row['TREE_DATE']; ?>"><br>
/ 01 /          Week [mm/dd/yyyy]:<input type="number" name="TREE_week" value="<?php echo $row['TREE_WEEK']; ?>"><br> /* 01 */
                Day of the Week: <select name="TREE_day">
                    <option value="MONDAY">Monday</option><br>
                    <option value="TUESDAY">Tuesday</option><br>
                    <option value="WEDNESDAY">Wednesday</option><br>
                    <option value="THURSDAY">Thursday</option><br>
                    <option value="FRIDAY">Friday</option><br>
                    <option value="SATURDAY">Saturday</option><br>
                    <option value="SUNDAY">Sunday</option><br>
                </select><br>
                Number Of Tree Events:<input type="number" name="TREE_events" value=" "><br></u>
                <input type="submit" value="Submit">

            </span>
        </form>
    </div>

Handler:

    <?
        $TREE_UPDATED = $_POST['TREE_updated'];
        $TREE_WEEK = $_POST['TREE_week'];
        $TREE_DAY = $_POST['TREE_day'];
        $TREE_EVENTS = $_POST['TREE_events'];

 / 02 /     $objConnect = oci_connect("user", "pass", "(description=(address=(protocol=tcp)(host=host)(port=1533))(connect_data=(service_name=sid)))");
        $weekSQL =  "SELECT * FROM INTOXDM.LSS_TREE WHERE WEEK = '$TREE_WEEK'";
        $weekParse = oci_parse($objConnect, $weekSQL);  
        $weekExecute = oci_execute($weekParse);
 \ 02 \     $week = oci_fetch_all($weekParse,$week1);

        if($week = 1)) {
            $updateSQL =  "UPDATE INTOXDM.LSS_TREE SET 
                    $TREE_DAY = '$TREE_EVENTS' 
                    WHERE WEEK = '$TREE_WEEK'";

            $updateParse = oci_parse($objConnect, $updateSQL);  
            $updateExecute = oci_execute($updateParse); 
        } else {
            $insertSQL = "insert into INTOXDM.LSS_TREE (WEEK, '$TREE_DAY') values ('$TREE_WEEK', '$TREE_EVENTS')";
            $insertParse = oci_parse($objConnect, $insertSQL);  
            $insertExecute = oci_execute($insertParse); 
        }

    ?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答