ryanfilard Posted July 22, 2011 Share Posted July 22, 2011 The results still return empty even when I type in the exact field name. $idea = $_REQUEST['s']; mysql_select_db($database_Users, $Users); $query_search = "SELECT * FROM users WHERE username AND fname AND lname AND tags LIKE '$idea'"; $search = mysql_query($query_search, $Users) or die(mysql_error()); $row_search = mysql_fetch_assoc($search); Quote Link to comment https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 22, 2011 Share Posted July 22, 2011 username AND fname AND lname AND tags ^^^ The above is logically AND'ing the contents of each of those columns together, which most likely is a TRUE value (unless you have FALSE and/or NULL values), then trying to see if TRUE LIKE '$idea' What exactly are you trying to accomplish? Quote Link to comment https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/#findComment-1245985 Share on other sites More sharing options...
ryanfilard Posted July 22, 2011 Author Share Posted July 22, 2011 I am making a script to search the users in my database based on there username, tags, real name Quote Link to comment https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/#findComment-1246001 Share on other sites More sharing options...
PFMaBiSmAd Posted July 22, 2011 Share Posted July 22, 2011 So, you want to match rows where any portion of the username is like $idea or any portion of the fname is like $idea or any portion of the lname is like $idea or any portion of the tags is like $idea? SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%' Quote Link to comment https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/#findComment-1246003 Share on other sites More sharing options...
ryanfilard Posted July 22, 2011 Author Share Posted July 22, 2011 yes Quote Link to comment https://forums.phpfreaks.com/topic/242598-mysql-search-not-working/#findComment-1246168 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.