PHP Oracle更新表错误 - oci_execute ORA-00933

I've managed to get Select and Create statements working but currently got an issue with Update statements using PHP.

Result of 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);
php
duanfaxin7014
duanfaxin7014 埃里克森这就是我最初设置的方式,但是自从我收到错误后,我将其更改为其他论坛的工作方式。
一年多之前 回复
doupu2722
doupu2722 谢谢,@vmaroli工作,菜鸟错误的我。
一年多之前 回复
doomm4711
doomm4711 您还应该考虑使用绑定参数,而不是将未转义的用户数据直接注入到查询中。您可以在手册中查看示例。
一年多之前 回复
dongtuo6562
dongtuo6562 似乎有一个错字。在$CountryID之后删除update语句中的最后一个右括号
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐