• 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

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

protect images from being copied

MySQL default time format UTC or GMT?

Pages are working fine on localhost but not running on the hosting server

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Laravel Schedule not sending email

Installing Composer - Internal Error

With doctrine ODM, can I embed many subdocuments in a main document?

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Xdebug in Laravel is not working with VSCode

laravel MVC execution flow

How do I truncate a decimal in PHP?

Getting values for an enum?

How to Install Composer Require doctrine/dbal

PHP Array split string and Integers

About Contact Privacy policy Terms and conditions