Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Will someone help with this MySQL Query?

Posted on 2008-10-21
2
Medium Priority
?
214 Views
Last Modified: 2013-11-19
I can't figure out why this query still shows results where PaidID=''.

The url calling this would be: ...?page=listing/results&State=FL

OR

$SEARCH="FL"; << Session

if (isset($_SESSION['search'])){
$SEARCH=$_SESSION['search'];
 
if (!ereg('[^0-9]', $SEARCH)){$searchResult = mysql_query("SELECT * FROM members WHERE ZipCodes LIKE '%$SEARCH%' AND PaidID!='' ");}
 
elseif (!ereg('[^A-Z]', $SEARCH) && (strlen($SEARCH) == 2)){
$searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='' 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
 
(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%')
 
AND PaidID!=''
 ");
 
}
 
elseif ($SEARCH=="EXAMPLE"){
$searchResult = mysql_query("SELECT * FROM members WHERE PaidID!='' ORDER BY RAND() LIMIT 5");
}
 
else{
$searchResult = mysql_query("SELECT * FROM members WHERE Counties LIKE '%$SEARCH%' OR Counties2 LIKE '%$SEARCH%' OR Counties3 LIKE '%$SEARCH%' OR Counties4 LIKE '%$SEARCH%'  PaidID!='' ");
}
 
if (!$searchResult){die(mysql_error());}
	
$num_rows= mysql_num_rows($searchResult);
 
}
 
if ($num_rows==0){include ("pages/listing/results_none.php");}
else{include ("pages/listing/results_found.php");}

Open in new window

0
Comment
Question by:phpretard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
yeruhn earned 2000 total points
ID: 22767102
Use brackets in your query. Like:

SELECT * FROM members WHERE PaidID!='' AND (LicState LIKE '%$SEARCH%' OR LicState2 LIKE '%$SEARCH%' OR LicState3 LIKE '%$SEARCH%' OR LicState4 LIKE '%$SEARCH%' )

Dependent on what you want to select...
0
 

Author Closing Comment

by:phpretard
ID: 31508229
Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question