-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
  • 37,241
  • 25
  • 195
  • 267
Thiers
  • 23
  • 7

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,242,037
  • 58
  • 646
  • 786