Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Search result

New Here ,
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

I want to find out what the correct syntax would be to use when querying multiple columns. What I have is:

mysql_select_db($database_LastMinuteConfirm, $LastMinuteConfirm); $province = $_POST['province']; $near_city = $_POST['near_city']; $accomm_type = $_POST['accomm_type']; $norm_price_range = $_POST['norm_price_range']; $query_Recordset1 = "SELECT * FROM lastminuteconfirm WHERE province = %$province% AND near_city = %$near_city% AND accomm_type = %$accomm_type% AND norm_price_range = %$norm_price_range%"; $Recordset1 = mysql_query($query_Recordset1, $LastMinuteConfirm) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1);

When I search it tells me: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%Gauteng% AND near_city LIKE %Pretoria (Tshwane)% AND accomm_type LIKE %boutique' at line 1".

What am I doing wrong?

TOPICS
Server side applications

Views

644
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 06, 2010 Sep 06, 2010

Are you trying to use the SQL wildcard with the equal (=) operator? You can only use a wildcard with the Like predicate.

Votes

Translate
LEGEND ,
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

Are you trying to use the SQL wildcard with the equal (=) operator? You can only use a wildcard with the Like predicate.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

Yeah, thanks. You set me thinking with your wildcard and I realised I only had one parameter running. Stupid of me. Will make sure next time before I waste my own or anyone elses' time again bby posting obvious questions. Anyway, thanks.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

I don't see it as a waste of time. Sure, figuring things out on your own is usually better, but sometimes we need to ask questions, and with the help of many of the experienced users here like bregent, we not only get our questions answered but it helps others too who may be having similar issues. Even if someone isn't having the same problem - I don't know how many times I've come across tidbits like this, maybe even bookmarked the page and it came in handy later on. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2010 Sep 08, 2010

Copy link to clipboard

Copied

LATEST

Thanks Lon

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines