Hello I try to make this prepared statement but the problem is that
"$search" is in fact not inserted by bindparam. Could you explain me the
reason, and tell me how could i make this prepared statement. Thank you very much.

Here is the code:

$query = $bdd->prepare('SELECT * FROM produits WHERE nom LIKE :search LIMIT :entry, :item_per_page') Or die(print_r($bdd->errorInfo()));

$query->bindParam('search', $search, PDO::PARAM_STR);
$query->bindParam(':entry', $entry, PDO::PARAM_INT);
$query->bindParam(':item_per_page', $item_per_page, PDO::PARAM_INT);
$query->execute();  

    I notice that you're trying to bind it to [font=monospace]search[/font], not [font=monospace]:search[/font]. That might be an issue.

      Thanks for the notification, but it still doesn't work...

        Problem fixed by formating $search like this:

        $search = '%' .$search. '%'; //Format for LIKE

        Thanks for help.

          Weedpacket;11037225 wrote:

          [font=monospace]search[/font], not [font=monospace]:search[/font]

          The prefix : is only needed in the actual query.

            Write a Reply...