php - Add a variable inside a mysql query -
i have variable $text = "sometexthere"
i add variable $text
inside following mysql query instead of sometexthere
$query = "select sum(nbr) sum table2 name '%sometexthere%'";
i tried doing in many ways like
$query = "select sum(stats) sum download filename '%' . $text . '%'";
and
$name = "'%' . $text . '%'"; $query = 'select sum(stats) sum download filename '.$name.'';
but not working :/
try with
$query = "select sum(stats) sum download filename '%$text%'";
and avoid line
$name = "'%' . $text . '%'";
or try this,
$name = "%".$text."%"; $query = "select sum(stats) sum download filename '$name'";
Comments
Post a Comment