N
N
NataliaCh2018-02-09 10:27:57
PHP
NataliaCh, 2018-02-09 10:27:57

Why is there an error in the prepared expression?

if i do that

$string = "'%бла-бла%', '%бла-бла%', '%бла-бла%'";    
$rs->execute(array($string));

Then an error occurs
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

If I stupidly substitute the same thing in the expression
$rs->execute(array('%бла-бла%', '%бла-бла%', '%бла-бла%'));

That is no error.
What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dart, 2018-02-09
@NataliaCh

So you substitute the string where the array should be. Then it should be like this:
$rs->execute(explode(', ', $string));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question