首页 > 解决方案 > PHP Oracle 更新表错误 - oci_execute ORA-00933

问题描述

我已经设法让 Select 和 Create 语句正常工作,但目前使用 PHP 的 Update 语句存在问题。

countryProcessor.php 的结果

Warning: oci_execute(): ORA-00933: SQL command not properly ended in /studenthome.hallam.shu.ac.uk/STUDENTHOME8/8/b4025068/public_html/processor/countryProcessor.php on line 60 

CountryID 18
GDP 109
Country Name Australia
Rows Affected 0

CountryProcessor.php

if(isset($_POST['CountryID'])) {
            $CountryID = $_POST['CountryID'];
        }
        if(isset($_POST['CountryName'])) {
            $CountryName = $_POST['CountryName'];
        }
        if(isset($_POST['Gross'])){
            $Gross = $_POST['Gross'];
        }


        $stmt = oci_parse($conn, "UPDATE COUNTRY SET COUNTRYNAME = '$CountryName', GDP = $Gross WHERE COUNTRYID = $CountryID)");

        // oci_bind_by_name($stmt, ":CountryID", $CountryID);
        // oci_bind_by_name($stmt, ":CountryName", $CountryName);
        // oci_bind_by_name($stmt, ":GDP", $Gross);


        oci_execute($stmt);
        $Affected = oci_num_rows($stmt);
        oci_commit($conn);

        echo "CountryID" . ' ' . $CountryID . "<br>";
        echo "GDP" . ' ' . $Gross . "<br>";
        echo "Country Name" . ' ' . $CountryName . "<br>";
        echo "Rows Affected" . ' ' . $Affected;
        // if(count($Affected) > 0){
        //  header("Location: ../index.php?Success=$CountryName has been updated!");
        // } else {
        //  header("Location: ../index.php?Danger=$CountryName hasn't been updated!");
        // }

        oci_free_statement($stmt);
        oci_close($conn);

标签: phporacle11goracle-sqldeveloperpsql

解决方案


推荐阅读