The Little Guy Posted April 2, 2007 Share Posted April 2, 2007 What is wrong with this SQL? When I run it in PHPMyADMIN, and switch $pass with a word I copied from the php admin SQL such as Aaron, It returns No Results, But there should Be results. What is wrong? SELECT * FROM common_words WHERE word='$pass' Quote Link to comment Share on other sites More sharing options...
Wildbug Posted April 2, 2007 Share Posted April 2, 2007 Prima facie, nothing appears wrong, syntactically. You need to give more diagnostic information. Try checking for error codes returned after attempting to execute this query. Are you sure $pass contains what you want it to contain and is being parsed correctly? What is your table structure? Etc, etc, etc. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 2, 2007 Author Share Posted April 2, 2007 Here is the Table I am using I changed the name of the word column to wrd (it didn't do anything). I changed the name of the table from common_words to cwords This code runs error free, but doesn't return results. The first one is the table structure, and the second is the SQL query in action. If you compaire the two, I used Aaron, for the SQL (img 2), and Aaron is in the database (img 1). [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Wildbug Posted April 3, 2007 Share Posted April 3, 2007 Okay, that is weird. The only thing that comes to mind is that there might be some trailing whitespace in the 'wrd' column. I.e., maybe instead of "Aaron" it's actually "Aaron " or "Aaron\n" or something so MySQL won't match with the equal sign. You could try some other query like "...WHERE wrd RLIKE 'Aaron'" or "...wrd LIKE 'Aaron%'". Depending on how you inserted your dictionary into the database, that might be a possibility. (I'm not familiar with PHPMySQLAdmin, so I don't know what caveats/trouble might be related to that.) Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted April 3, 2007 Author Share Posted April 3, 2007 Using A % before and after seems to work I think I will go with that. I added them by finding a dictionary, it was a txt file, with one word per line, so I just exploded at a \n and then did a foreach to add each one into the database. Quote Link to comment Share on other sites More sharing options...
btherl Posted April 3, 2007 Share Posted April 3, 2007 Using the % will kill efficiency though, if your table is large. Particularly if you have it at the start. If you exploded with \n, it's possible you have a dos format file, and so you have a hidden \r in every string in your database. You can try using some of the string length and substring functions in mysql to investigate further. Quote Link to comment Share on other sites More sharing options...
Wildbug Posted April 3, 2007 Share Posted April 3, 2007 Right, you don't want to continue using wildcards (%); that was just to help diagnose the problem. You'll want to fix the entries before you use that table. Quote Link to comment 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.