0

I'm using something like this to get values from my database, but it's not returning anything. No errors, but also no data when I know there should be. I'm sure I have some syntax error, but can't figure out where:

$search_crit = $_POST['search_items'];
$sql1 = "SELECT `Provider Name`, `State Abbrv`, `zip_code` FROM `myTable` 
where `Provider Name` like '%:criteria%' group by `Provider Name`";
$stmt = $dbh->prepare($sql1);
$stmt->bindParam(':criteria', $search_crit, PDO::PARAM_STR, 100);
$stmt->execute();
$result1 = $stmt->fetchAll();

In this case, $search_crit is a string entered by the user on the front end. I've ran this query by "hardcoding" a value in for :criteria, so I know it works in principle, but can't figure out what my issue is when I try to pass the value with PDO.

jonmrich
  • 4,233
  • 5
  • 42
  • 94

0 Answers0