I have a simple piece of text from a form I want to pass to a placeholder and it works on other pieces of text. For whatever reason when I search with the word "fun", the script fails.
Here is my code. Normally, this is straight forward, but I can't seem to wrap my head around this one. Any thoughts are appreciated.
$search = $_POST['searchInput'];
$search = strtolower($search);
$search = '%'.$search.'%';
try {
$sqlSearch = "SELECT items.item_id,item_detail,auc_id,item_desc,categories,min_bid_increment,auc_start,auc_end,display_item,bidder,amount_bid FROM items
LEFT JOIN bid_history ON items.item_id = bid_history.item_id
WHERE org_id = :orgid
AND auc_id NOT LIKE 'live%'
AND display_item = '1'
AND item_detail LIKE :searchInput
OR item_desc LIKE :searchInput
OR items.item_id LIKE :searchInput
ORDER BY items.item_id ASC, bid_history.amount_bid DESC;";
$sSearch = $pdo->prepare($sqlSearch);
$sSearch->bindValue(':orgid',$org_id);
$sSearch->bindValue(':searchInput',$search);
$sSearch->execute();
$resultsSearch = $sSearch->fetchAll();
}
catch (PDOException $e) {
echo $e;
}
EDIT:
If I manually put this query into my database, I get results back.
SELECT items.item_id,item_detail,auc_id,item_desc,categories,min_bid_increment,auc_start,auc_end,display_item,bidder,amount_bid FROM items
LEFT JOIN bid_history ON items.item_id = bid_history.item_id
WHERE org_id = 'CHS102915'
AND auc_id NOT LIKE 'live%'
AND display_item = '1'
AND item_detail LIKE '%fun%'
OR item_desc LIKE '%fun%'
OR items.item_id LIKE '%fun%'
ORDER BY items.item_id ASC, bid_history.amount_bid DESC