Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-25-2007, 01:15 PM   #1
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
MySQL gurus in here now please.

So I've been trying to get a damn search option to work with one of my mainstream projects for the past day or so but it's just not working. Here's the query I'm using:
Quote:
$trysrch = @mysql_query("select * from table_name where item_name like '$srch' || item_name2 like '$srch' || item_name3 like '$srch' && area = '$place' order by item_name asc");
Looks fine right? According to documentation this should work. Well, all of the selects for the OR (||) work, but once it gets to the AND part it seems to just overlook it and doesn't do anything. It does finish successfully (as in no errors) but it doesn't use the AND part (doesn't further narrow the results by executing the actual logic).
My questions: Why doesn't this work? What am I doing wrong if it's wrong?
This has been frustrating the shit out of me.
Thanks to all who will be kind enough to reply.
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2007, 01:17 PM   #2
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
put the OR parts in parenthesis, i think that should fix it

$trysrch = @mysql_query("select * from table_name where (item_name like '$srch' || item_name2 like '$srch' || item_name3 like '$srch') && area = '$place' order by item_name asc");
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2007, 01:18 PM   #3
WarChild
Let slip the dogs of war.
 
WarChild's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Bermuda
Posts: 17,263
You don't understand how "OR" works. Read more grasshopper, read more.
__________________
.
WarChild is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2007, 01:21 PM   #4
WarChild
Let slip the dogs of war.
 
WarChild's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Bermuda
Posts: 17,263
I believe your statement is being evaluated like this:

item_name like '$srch'
OR
item_name2 like '$srch'
OR
item_name3 like '$srch' AND area = '$place' order by item_name asc
__________________
.
WarChild is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2007, 01:27 PM   #5
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
Quote:
Originally Posted by tical View Post
put the OR parts in parenthesis, i think that should fix it

$trysrch = @mysql_query("select * from table_name where (item_name like '$srch' || item_name2 like '$srch' || item_name3 like '$srch') && area = '$place' order by item_name asc");
Thank you very much. It works great now. Guess I should read more.
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-25-2007, 01:28 PM   #6
BT
Confirmed User
 
BT's Avatar
 
Join Date: Apr 2002
Location: Ft liquordale FL
Posts: 6,481
go fuck your self
__________________

IS Prime Hosting Bald Head Shine "BT" The American Dream, baby!
" THE HOST WITH THE MOST!"



My ICQ 122994792
BT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.