I am trying to search for a email with the same domain in a mysql database using using SQL LIKE as in
$search=$_POST['searchTickets'];
$from=$_POST['fromm'];
$to=$_POST['too'];
$q=mysqli_query($conn,"select * from mytickets WHERE email LIKE '%$search' AND dt BETWEEN '$from' AND '$to' ");
Although the $search have a string (example mydomain.com) that correspond to values found in mytickets table, email column (example [email protected]), the mysqli_query keep returning zero results.
And somehow when I replace email LIKE '%$search' with email LIKE '%mydomain.com' it return the result I'm looking for. could it be sql is taking $search in '%$search' as a string? if so whats the right way to make SQL take it as PHP variable?
$searchdoes not include the right value.$searchwas picking up the wrong value. Thanks alot.