Gurus, I am attempting to pass a form variable into ORACLE select statement. It works when the variable value is hardcoded but when I try to include it as variable it bombs out.
Here is my code.
Eventually I'd like to pass the both the Grocery and st variable to the SELECT statement.
I have tried the OCIbindbyname but I can't getthat to work either.
Here is my code.
Code:
<?php
$st = $_REQUEST['searchterm'];
print_r($st);
echo "<html> \n <body>";
if($dbconnection = OCILogon("", "", ""))
{
echo "We have connected <br>";
$sql="SELECT * FROM BLD WHERE BLDVF4C LIKE '%Grocery%'
and BLDVF7C LIKE '%$st%'";
print_r($sql);
$stmt = OCIParse($dbconnection,$sql);
OCIExecute($stmt);
$counter = 0;
while (OCIFetch($stmt)) {
$counter++;
echo "<table border=1 width=><tr><td>";
echo OCIResult($stmt, "BLDKEYI")."</td><td>";
echo OCIResult($stmt, "BLDBEZC")."</td><td>";
echo OCIResult($stmt, "BLDFNMC")."</td><td>";
echo OCIResult($stmt, "BLDVF4C")."</td><td>";
echo OCIResult($stmt, "BLDVF7C")."</td></table>";
}
OCIFreeStatement($stmt);
}
else
{
echo "we have no connection";
}
?>
Eventually I'd like to pass the both the Grocery and st variable to the SELECT statement.
I have tried the OCIbindbyname but I can't getthat to work either.