Page 1 of 1

sql not equal

Posted: Mon May 30, 2005 7:08 pm
by psychotomus

Code: Select all

$sql = mysql_query("SELECT id, url, title, descriptionFROM {$prefix}pages WHERE category = $c AND accepted = 'y' AND subtype != '4' ORDER BY title LIMIT ".($s-1).",$n");

whats wrong with this. It will work fine without subtype != '4'. should it be <> instead or NOT or what?

Jcart | Please use

Code: Select all

tags when posting php code. Review   [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon May 30, 2005 7:37 pm
by Burrito
did you try it?

it should be "<>", but you gotta try it to know :?

Posted: Mon May 30, 2005 8:17 pm
by psychotomus
neither work but i did an alternative way.

Posted: Mon May 30, 2005 8:49 pm
by John Cartwright
heres a list of symbols

specifically
!= (not equal), Comparison Functions and Operators
Perhaps show us your table structure? I don't see anything obvious why it wouldn't work.. but I might just have missed it.

Posted: Mon May 30, 2005 9:46 pm
by Ambush Commander

Code: Select all

$var = (0 !== false)
//true
$var = (0 != false)
//false
EDIT- Err... maybe that's not what he meant.

Posted: Tue May 31, 2005 1:53 am
by patrikG
remove the curly brackets in your SQL statement. If you want to insert variable values, a clean way would be:

Code: Select all

"SELECT me FROM thousands WHERE ".$i."<>'you'";