1
<?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);
?>  

我得到这个输出:

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
4

1 回答 1

5

这里有很多问题。

  1. 最简单的答案是您需要使用单引号 ( ') 而不是双引号(请参阅Oracle 数据库 SQL 参考中的字符串文字
  2. 你真的应该使用类似的东西oci_bind_by_name而不是盲目地将你的值插入到查询中。为您节省解析和潜在的 SQL 注入。
  3. ociparse自 PHP 5.4起ociexecute已弃用。而不是这些,您应该分别使用oci_parseoci_execute
于 2012-07-19T21:38:13.473 回答