I have a query that fails It seems to be the AND statement that is failing.
if(isset($_POST['sea']) && $_POST['sm'] !==''){
$sm = trim($_POST['sm']);
$sql = "SELECT * FROM `memorials` WHERE `fname` LIKE '$sm%' OR `lname` LIKE '$sm%' OR `comments` LIKE '$sm%' AND `status` = '2' ";
$q = $conn->prepare($sql);
$q->execute();
I have added\removed backticks
, the 'status = '2' fails.
The following statement works in phpmyadmin
SELECT * FROM `memorials` WHERE `fname` LIKE 'test%' AND status = '2'
This statement fails in phpmyadmin
SELECT * FROM `memorials` WHERE `fname` LIKE 'test%' OR `lname` LIKE 'test%' AND status = '2'
This query searchs comment AND clause works, but ignore fname and lname
$sql = "SELECT * FROM memorials WHERE `fname` OR `lname` OR `comments` LIKE '$sm%' AND status = '2' ";
Does anyone have a suggestion where this is (I am) failing
Thank you
Gary