I'm running the following query on a table:
$query = "SELECT count(*) as count from photos where img_type='story' AND article_id='1' and sortorder='r' AND img_id != 115";
and I keep getting a count of 1.
Problem is, in the table sortorder is either an integer or NULL. When I set sortorder to a number it works as expected - if there's another photo with that sortorder I get a count, if there isn't I get no count. Why would setting sortorder to a letter give me a result?
Most puzzling....
If this worked as expected, I have a second validation routine that confirms the entry is an integer, within a set range. It should be falling right through the first check (the 'count') with a count of zero - shouldn't it?