phpretard Posted October 21, 2008 Share Posted October 21, 2008 I can't figure out why this query still shows results where PaidID='1'. The url calling this would be: ...?page=listing/results&State=FL OR $SEARCH="FL"; << Session if (!ereg('[^0-9]', $SEARCH)){$searchResult = mysql_query("SELECT * FROM members WHERE ZipCodes LIKE '%$SEARCH%' AND PaidID!='1' ");} elseif (!ereg('[^A-Z]', $SEARCH) && (strlen($SEARCH) == 2)){ $searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='1' AND LicState LIKE '%$SEARCH%' OR LicState2 LIKE '%$SEARCH%' OR LicState3 LIKE '%$SEARCH%' OR LicState4 LIKE '%$SEARCH%' "); } elseif (isset($_GET['State'])){ $searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='1' AND (LicState='$State' AND Counties LIKE '%$SEARCH%' ) OR (LicState2='$State' AND Counties2 LIKE '%$SEARCH%') OR (LicState3='$State' AND Counties3 LIKE '%$SEARCH%') OR (LicState4='$State' AND Counties4 LIKE '%$SEARCH%') "); } elseif ($SEARCH=="EXAMPLE"){ $searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='1' ORDER BY RAND() LIMIT 5"); } else{ $searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='1' AND Counties LIKE '%$SEARCH%' OR Counties2 LIKE '%$SEARCH%' OR Counties3 LIKE '%$SEARCH%' OR Counties4 LIKE '%$SEARCH%' "); } Could anyone tell me? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/129385-help-with-a-query/ Share on other sites More sharing options...
DeanWhitehouse Posted October 21, 2008 Share Posted October 21, 2008 I don't think you can use this != operator in Mysql statements try <> or PaidID = 0 ?? Quote Link to comment https://forums.phpfreaks.com/topic/129385-help-with-a-query/#findComment-670758 Share on other sites More sharing options...
phpretard Posted October 21, 2008 Author Share Posted October 21, 2008 It still shows all even with PaidID='0' Quote Link to comment https://forums.phpfreaks.com/topic/129385-help-with-a-query/#findComment-670776 Share on other sites More sharing options...
DeanWhitehouse Posted October 21, 2008 Share Posted October 21, 2008 Try mysql_query("SELECT * FROM members WHERE PaidID <> '1' AND ZipCodes LIKE '%".$SEARCH."%'") or die(mysql_error()); //or try mysql_query("SELECT * FROM members WHERE PaidID = '0' AND ZipCodes LIKE '%".$SEARCH."%'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/129385-help-with-a-query/#findComment-671114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.