• 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

array_map triple dimensional array [duplicate]

generate an Excel file using PHP

How to downgrade or install a specific version of Composer?

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

Transpose and flatten multiple rows of array data [duplicate]

Laravel views are showing from cache on one server but works fine on other server

Laravel Livewire: jQuery not working in child component loaded via @if statement

Filter WooCommerce related products by Polylang language

"There is no active transaction" when refreshing database in Laravel 8.0 test

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

How to disable only_full_group_by option in Laravel

laravel 5.6 bulk inserting json data

Using PHP to connect to a remote MSSQL database

Woocommerce Checkout - Add conditional field required if one field is filled

What is my SQL missing?

About Contact Privacy policy Terms and conditions