2015-02-11 70 views
5

01745:無效的主機/綁定變量名稱警告運行rollowing代碼時。我不確定爲什麼會發生這種情況,請幫忙!我覺得我的綁定肯定有問題,但是我看不出有什麼問題。我的$ Start和$ End變量看起來像DD-MM-YY。我列出了下面的PHP代碼。謝謝!PHP ORA-01745:無效的主機/綁定變量名稱警告

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 

回答

13

的問題是您正在使用保留的甲骨文字(即我想 「:結束」 是罪魁禍首),用於綁定變量的名稱,不允許。

嘗試將其更改爲「:完成」或類似的,它應該工作。

+0

嘿謝謝你的重播我改變了:結束:完成,我仍然收到同樣的錯誤! – vector 2015-02-11 22:50:12

+0

我必須改變開局。但那工作!謝謝。 – vector 2015-02-11 22:52:44

相關問題