• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Correct way to use LIKE '%{$var}%' with prepared statements?

phpmysqlsqlmysqli


PHP Snippet 1:

$likeVar = "%" . $yourParam . "%";
$stmt = $mysqli->prepare("SELECT * FROM REGISTRY where name LIKE ?");
$stmt->bind_param("s", $likeVar);
$stmt->execute();

Related Snippets

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

laravel automatically deletes server.php on php artisan serve

Multiply each value in array using array_map function

php mysql + create a friend request system

Undefined Array Key error when uploading image on php

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

how to upload binary image to sql server using php laravel

How can I create a Download Page with post php method?

renameColumn migration fails for existing column with columns does not exist error

how to make my own auto increment in php?

What will the best solution for this multiple optional filter?

Implode array with array of glue strings

Access relation of pivot table in Laravel

Insert multidimensional array to codeigniter cart

laravel sanctum Route [login] not defined

About Contact Privacy policy Terms and conditions