php - Binding parameters to mysql query -
i want result mysql database php.
i using query one:
select * images images.name ? or images.title ?
and how bind parameters query:
$f_for = "%". $filter_for ."%"; $stmt->bind_param('ss', $f_for, $f_for);
if replace questionmarks ?
made search string, query looks this:
select * images images.name '%searchforthis%' or images.title '%searchforthis%'
and execute directly (not php, phpmyadmin or directly via terminal), correct/positive result (ie getting rows back, search string matches value in 1 of 2 columns).
using parameterized query not errors, empty result (ie 0 rows). tried different string formats, seems none of these work either.
$f_for = "'%". $filter_for ."%'"; $f_for = "%{$filter_for}%";
how correctly bind parameters? doing wrong or problem?
this 1 way can it, , involves lot less fiddling $filter_for
$sql = "select * images images.name ? or images.title ?" $stmt = $conn->prepare($sql); $param = "%$filter_for%"; $stmt->bind_param('ss', $param, $param);
Comments
Post a Comment