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 5 of 5

Thread: SELECT mis mask

  1. #1
    New Coder
    Join Date
    Feb 2009
    Location
    Køge, Denmark
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    SELECT mis mask

    what is wrong with this line.

    because it dont care about the aktiveret (if it is 1 or 0 it takes it with anyway)

    $sqlquery = "SELECT * FROM profiler WHERE aktiveret = '1' AND navn LIKE '%".$searchterm."%' OR html LIKE '%".$searchterm."%' ";
    $query = mysql_query($sqlquery) or die(mysql_error());
    if(mysql_num_rows($query) == 0){

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    If it's an integer filed, remove the quotes around the value
    Code:
    ....WHERE aktiveret = 1 ....
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2009
    Location
    Køge, Denmark
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hi - no it still take the aktiveret with if the value of it is 0

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Umm..
    Code:
    $sqlquery = "SELECT * FROM profiler WHERE 
    aktiveret = 1 AND navn LIKE '%".$searchterm."%' OR html LIKE '%".$searchterm."%' ";
    is equivalent to

    Code:
    $sqlquery = "SELECT * FROM profiler WHERE 
    (aktiveret = 1 AND navn LIKE '%".$searchterm."%') OR html LIKE '%".$searchterm."%' ";
    So the query will return all case that matches
    Code:
    html LIKE '%".$searchterm."%' ";
    I think you need
    Code:
    $sqlquery = "SELECT * FROM profiler WHERE aktiveret = 1 AND 
    (navn LIKE '%".$searchterm."%' OR html LIKE '%".$searchterm."%') ";
    Last edited by abduraooft; 02-17-2009 at 09:06 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    gjessing (02-17-2009)

  • #5
    New Coder
    Join Date
    Feb 2009
    Location
    Køge, Denmark
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    YES YES

    you are the greatest.

    Thanks a lot - now it works like cream


  •  

    Tags for this Thread

    Posting Permissions

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