-1

I created code for select query for MySQL in PHP.

The code:

$vericek4 = $baglanti2 -> prepare ("select no from urunlist where urunad like '%?%'");
$vericek4 -> bindParam(1, $aramayss);
$vericek4 -> execute();

$satirsay2 = $vericek4 -> rowCount();

I have data in $aramayss. But $satirsay2 is null.

Cœur
  • 34,719
  • 24
  • 185
  • 251
Thiers
  • 23
  • 6

1 Answers1

2

It "works". It just doesn't do what you expect. The ? is in a string, so it is not substituted with the parameter value.

You can construct the like pattern using concat():

select no from urunlist where urunad like concat('%', ?, '%')

Alternatively, add the wildcards in PHP, and just use:

select no from urunlist where urunad like ?
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709