Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass PHP form variable to SELECT query in Oracle.

Status
Not open for further replies.

iteach2

Technical User
Sep 16, 2001
120
US
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.
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top