Written by Reko Srowako
Thursday, February 11th, 2010
Hi all. I’m stuck on a problem involving php and mysql. I think it’s a mysql problem. In short, I have a form with two text fields where a user is able to enter the string which they would like to search. It searches the fields authors, paper title and journal title named respectively as “authors”, “paper” and “journal” in mysql. I have a bunch of “if” statements in my php script that will add relevant commands to my sql query (that is $sql = select * from journals where true etc..).
Now, if I enter a word in only one of the search boxes then it will work. However if I type into both boxes, it will only search the word that is in the first search box. The query for when a word is typed into both fields is
SELECT * FROM journals WHERE TRUE AND authors LIKE ‘%text%’ OR paper LIKE ‘%text%’ OR journal LIKE ‘%text%’ AND authors LIKE ‘%text2%’ OR paper LIKE ‘%text2%’ OR journal LIKE ‘%text2%’
The code when inserted into mysql seems to stop before the second AND. Can only one AND be used in mysql? I also typed the command in the mysql window and got the same result as I did through the php script so I’m pretty sure its something wrong with the command.
So is it possible to search two strings through mysql through multiple fields? I tried a MATCH command but it didn’t work (maybe I had used it wrongly though).
Any help is appreciated. Thank you in advance.
Possibly Related Posts:
- Tune Up Utilities 2010 Full Version Tested By Me
- Injecting – HTML
- Your Ideal Partner Online – Cheap Web Hosting
- Belajar tanpa Batas
- Linux Web Hosting is Often Less Expensive
The contest web hosting is increasing rapidly in the Internet world today. While some are willing to spend more money in hosting a 






