Reputation: 41
Can someone help me in this problem.
function get_shareSearch($conn, $searchBy) {
$id = "";
if(isset($_GET['share']))
{
$id = $_GET['share'];
if($id == "%")
{
$id = "This is not going to work";
}
}
$statement = db_create_statement($conn, "SELECT DISTINCT * FROM shares WHERE company LIKE '%" . $id . "%' OR issue_date LIKE '%" . $id ."%' ORDER BY $searchBy ASC" );
db_bind($statement, ':id', $id);
$resultset = db_fetch_resultset($statement);
return $resultset;
}
function db_bind($statement, $name, $value) {
return oci_bind_by_name($statement, $name, $value, 30);
}
Warning: oci_bind_by_name(): ORA-01036: illegal variable
can any one help me how to change variable id in the oracle statement so I could still have concatination plus to that to be able to bind the variable? Thank you.
db_bind($statement, ':id', $id);
Upvotes: 1
Views: 264
Reputation: 8858
To bind variables in a String they have to be concatenated (oracle notation):
SELECT DISTINCT * FROM shares WHERE company LIKE '%' || :id || '%' OR issue_date LIKE '%' || :id || '%' ORDER BY $searchBy ASC
Upvotes: 2