Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-17-2009, 07:16 AM   PM User | #1
gjessing
New Coder

 
Join Date: Feb 2009
Location: Køge, Denmark
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
gjessing is an unknown quantity at this point
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)

Quote:
$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){
gjessing is offline   Reply With Quote
Old 02-17-2009, 08:24 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
If it's an integer filed, remove the quotes around the value
Code:
....WHERE aktiveret = 1 ....
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 02-17-2009, 09:00 AM   PM User | #3
gjessing
New Coder

 
Join Date: Feb 2009
Location: Køge, Denmark
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
gjessing is an unknown quantity at this point
hi - no it still take the aktiveret with if the value of it is 0
gjessing is offline   Reply With Quote
Old 02-17-2009, 09:03 AM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
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."%') ";
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

Last edited by abduraooft; 02-17-2009 at 09:06 AM..
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
gjessing (02-17-2009)
Old 02-17-2009, 09:08 AM   PM User | #5
gjessing
New Coder

 
Join Date: Feb 2009
Location: Køge, Denmark
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
gjessing is an unknown quantity at this point
YES YES

you are the greatest.

Thanks a lot - now it works like cream
gjessing is offline   Reply With Quote
Reply

Bookmarks

Tags
select

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:39 AM.


Advertisement
Log in to turn off these ads.