PHP ORA-01745: 无效 host/bind 变量名警告

PHP ORA-01745: invalid host/bind variable name Warning

01745: 当 运行 滚动代码时 host/bind 变量名警告无效。我不确定为什么会这样,请帮忙!我觉得我的绑定一定有问题,但我看不出有什么问题。我的 $Start 和 $End 变量看起来像 DD-MM-YY。我在下面列出了 PHP 代码。谢谢!

PHP:

<?php
$year_Echo = '2013';
$yearTruncation =  substr($year_Echo, 2);
$yearTruncationMinusOne = $yearTruncation-1;
$Start = ('1-OCT-'.$yearTruncationMinusOne);
$End = ('30-SEP-'.$yearTruncation);
echo "Start = ".$Start." End = ".$End." Year Truncation Minus One = ".$yearTruncationMinusOne."<br>";

/*** connect or WFO DB ***/
$db = oci_connect('query','pw','server:1521/view');
if (!$db){
  $e = oci_error();
  trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} 
$query = "SELECT * FROM db.cooldb WHERE (STATUS = 'ACTIVE' OR STATUS = 'CLOSED') AND NUMBER <> ' ' 
                                                                                                                    AND AMENDMENT_DATE_CREATED
                                                                                                                    BETWEEN :start AND :end
                                                                                                                    ORDER BY AMENDMENT_DATE_CREATED DESC";

$runQuery = oci_parse($db, $query);
oci_bind_by_name($runQuery, ":start", $Start);
oci_bind_by_name($runQuery, ":end", $End);
oci_execute($runQuery);

while($row = oci_fetch_array($runQuery, OCI_ASSOC+OCI_RETURN_NULLS))
{
    echo $row['AMENDMENT_DATE_CREATED']." ".$row['TITLE']."<br>";       
}
?>

错误:

Warning:
oci_execute() [function.oci-execute]: ORA-01745: invalid host/bind variable name

问题是您正在使用保留的 oracle 字(即我认为“:end”是罪魁祸首)作为绑定变量名称,这是不允许的。

尝试将其更改为“:finish”或类似的名称,它应该可以工作。