Oracle-00972:标识符太长我的SQL出了什么问题?

Jam*_*ele 1 php sql oracle

<?php

// This leaves the db connection in $conng require_once('/tms/http/html_docs/tease/csp/csp_tease.php');

    /* This a logging function. When called with:
     */

    function log_tkt_to_db($tkt_number, $date, $uid, $description, $conng)
    {
        echo "$tkt_number|$date|$uid|$description<br>";

        $sqlinsert = "insert into TEASE_TKTLOGS  VALUES ( \"$tkt_number\", \"$date\", \"$description\",  \"$uid\")";
        echo $sqlinsert . "<br>";
        $insert = OCIParse($conng, $sqlinsert);
        // OCIExecute($insert, OCI_COMMIT_ON_SUCCESS);
        OCIExecute($insert);
    }

log_tkt_to_db("00000000", "07/13/2012", "jt898u", "this a test, this is only a test", $conng);
?>  
Run Code Online (Sandbox Code Playgroud)

我得到这个输出:

00000000|07/13/2012|jt898u|this a test, this is only a test
insert into TEASE_TKTLOGS (TICKET, DATE_TIME, CHANGE_DESC, ATTUID) VALUES ( "00000000", "07/13/2012", "this a test, this is only a test", "jt898u")

Warning: ociexecute() [function.ociexecute]: ORA-00972: identifier is too long in /appl/tms/http/html_docs/tease/dblog.php on line 17
Run Code Online (Sandbox Code Playgroud)

and*_*dri 5

这里有很多错误.

  1. 最简单的答案是,你需要使用单引号('),而不是双引号(见字符串文字Oracle数据库SQL参考)
  2. 你真的应该使用类似的东西oci_bind_by_name而不是盲目地将你的值插入到查询中.为您保存解析和潜在的SQL注入.
  3. ociparse并且ociexecute自PHP 5.4起不推荐使用.你应该分别使用oci_parse和而不是这些oci_execute.