01745: invalid host/bind variable name warning when running the rollowing code. I am not sure why this is happening please help! I feel like it must be something wrong with my binding but I cannot see what is wrong about it. My $Start and $End variables look like DD-MM-YY. I have listed the PHP code below. Thank you!
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>";
}
?>
Error:
Warning:
oci_execute() [function.oci-execute]: ORA-01745: invalid host/bind variable name
The problem is you are using reserved oracle words (namely I think ":end" is the culprit) for a binding variable name, which is not allowed.
Try changing it to ":finish" or similar and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With