Search Engine Bug PHP&Mysql -
hi guys i've got problem in search engine. here's code:
$types = mysql_real_escape_string($_get['type']); //convertion de if ($types = "air") { $searchq = "lf"; }elseif ($types = "huile") { $searchq = "of"; }elseif ($types = "carburant") { $searchq = "kf"; }elseif ($types = "habitacle") { $searchq = "cf"; }elseif ($types = "eau") { $searchq = "wf"; }else{ $searchq = "df"; } $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq); $query = mysql_query("select * tproduct ssearch '%$searchq%'") or die("la recherche est impossible"); $count = mysql_num_rows($query); $result = mysql_query("select * tproduct ssearch '%$searchq%'");
but problem searchq
takes value of lf
.
where problem in code please?
if ($types == "air") { $searchq = "lf"; }elseif ($types == "huile") { $searchq = "of"; }elseif ($types == "carburant") { $searchq = "kf"; }elseif ($types == "habitacle") { $searchq = "cf"; }elseif ($types == "eau") { $searchq = "wf"; }else{ $searchq = "df"; }
you assigning instead of comparing. use ==
compare strings
see documentation here: http://php.net/manual/en/language.operators.comparison.php
a side note, should switch pdo or mysqli , use prepared statements. mysql_ functions deprecated.
Comments
Post a Comment