• 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

Why isn't my PHP exception working?

zsh: command not found: php

Yii Ajax Submit button

Query Optimization, changing the queries in the loop into a single processing query

Facebook PHP SDK - will not logout properly

Inserting Country Selection into MySQL PHP [duplicate]

Spam Filter in Contact Form

Prestashop webservice API creating cart rules

How to map the two arrays with a duplicate value?

PHP array sort and remove duplicates by two field values

How do I call a php file with axios?

laravel 5.6 bulk inserting json data

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

Extract string between first whitespace and last whitespace in php

php curl_exec() Connection refused when retrieving a remote image

About Contact Privacy policy Terms and conditions