...

View Full Version : search does not match properly [ was: any possible reason ]



CstAn
09-04-2006, 03:22 PM
i had created a search function on a web application.

the problem is, i try enter some of info to it, certain text can be found but certain text can be match although they are in database.

this my query:


$keywordu = strupper($keyword);
$keywordl = strlower($keyword);

$sql = "SELECT E.* FROM employes AS E, dvi_problem AS DV WHERE AS.empId = DV.empId AND (E.emp_name LIKE '%".$keyWordl."%' OR DV.reference LIKE '".$keywordi."''%".$keywordl."%' OR E.emp_name = '%".$keywordu."%' OR DV.reference LIKE '%".$keywordu."%')"

$query = mysql_query($sql, $db) or die('Fail to search.');


i test with direct copy the data from database, some string i copy can search it but some other string i copy direct it can work wo...

i try show out the variable $sql value, it show with not error, the keywordu n keywordl aslo show out the value when i print out the $sql variable.

any possible reason for it?

i had using php syntax.

thanks.

mic2100
09-04-2006, 09:45 PM
when looking at the code i notice that there is a problem with this line.




$sql = "SELECT E.* FROM employes AS E, dvi_problem AS DV WHERE AS.empId = DV.empId AND (E.emp_name LIKE '%".$keyWordl."%' OR DV.reference LIKE '".$keywordi."''%".$keywordl."%' OR E.emp_name = '%".$keywordu."%' OR DV.reference LIKE '%".$keywordu."%')"


DV.reference LIKE '".$keywordi."''%".$keywordl."%' is this part correct????

i think it shoud be something like

DV.reference LIKE '%".$keywordl."%'

or

DV.reference LIKE '%".$keywordi."%' OR DV.reference LIKE '%".$keywordl."%'

CstAn
09-05-2006, 10:06 AM
when looking at the code i notice that there is a problem with this line.




$sql = "SELECT E.* FROM employes AS E, dvi_problem AS DV WHERE AS.empId = DV.empId AND (E.emp_name LIKE '%".$keyWordl."%' OR DV.reference LIKE '".$keywordi."''%".$keywordl."%' OR E.emp_name = '%".$keywordu."%' OR DV.reference LIKE '%".$keywordu."%')"


DV.reference LIKE '".$keywordi."''%".$keywordl."%' is this part correct????

i think it shoud be something like

DV.reference LIKE '%".$keywordl."%'

or

DV.reference LIKE '%".$keywordi."%' OR DV.reference LIKE '%".$keywordl."%'


not....is me miss typing here....

i try search other text(also exits in DB) it can get the result, but with other text(aslo exits in DB) , it cant get leh..

anyother possible problem....

i m using php 4 n mysql



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum