note 102048 modified in mysqli-stmt.bind-param by danbrown

From: Date: Tue, 25 Jan 2011 13:58:00 +0000
Subject: note 102048 modified in mysqli-stmt.bind-param by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176290@lists.php.net to get a copy of this message
I had a problem with the LIKE operator This code did not work: <?php $test = $sql->prepare("SELECT name FROM names WHERE name LIKE %?%"); $test->bind_param("s", $myname); ?> The solution is: <?php $test = $sql->prepare("SELECT name FROM names WHERE name LIKE ?"); $param = "%" . $myname . "%"; $test->bind_param("s", $param); ?> --was-- I had a problem with the LIKE operator This code did not work: $test = $sql->prepare("SELECT name FROM names WHERE name LIKE %?%"); $test->bind_param("s", $myname); The solution is: $test = $sql->prepare("SELECT name FROM names WHERE name LIKE ?"); $param = "%" . $myname . "%"; $test->bind_param("s", $param); http://php.net/manual/en/mysqli-stmt.bind-param.php

« previous php.notes (#176290) next »