Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    148
    Thanks
    1
    Thanked 0 Times in 0 Posts

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

    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.
    Last edited by guelphdad; 09-04-2006 at 10:55 PM. Reason: proper thread title

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    when looking at the code i notice that there is a problem with this line.


    PHP Code:
    $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."%'

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    148
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mic2100 View Post
    when looking at the code i notice that there is a problem with this line.


    PHP Code:
    $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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •