kernelgpf Posted August 13, 2013 Share Posted August 13, 2013 (edited) I am trying to run queries against a table and running into very confusing problems. I keep returning "0" rows for obvious matches - attached is a screenshot of an example (query+"no results" and picture of table with value being searched for (perfect match). I've been pulling my hair out on this for hours - help and TIA! Edited August 13, 2013 by kernelgpf Quote Link to comment Share on other sites More sharing options...
kicken Posted August 13, 2013 Share Posted August 13, 2013 I'd guess there is a difference in the whitespace which you can't see by looking at the phpMyAdmin output since HTML collapses whitespace. Try replacing each space in the query with a % and see if it matches. Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted August 13, 2013 Author Share Posted August 13, 2013 I trimmed both values first, thanks anyway =/ nothing in the table will match properly - I'm actually writing a script to check against the incidentID and I started testing on the intersection field as well, something is wrong with the table I feel. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 13, 2013 Share Posted August 13, 2013 do not put column names inside quotes, it treats it as a string literal if you do Quote Link to comment Share on other sites More sharing options...
kicken Posted August 13, 2013 Share Posted August 13, 2013 (edited) Trim would only handle spaces at the beginning and end of a string. It wouldn't help with any space variations in the middle of the string. For instance if your database contained the value 1500 LA BRANCH(two spaces between words) your query would fail to match, even though it would appear as though it should when viewing the record in phpMyAdmin. Edited August 13, 2013 by kicken Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted August 13, 2013 Author Share Posted August 13, 2013 Okay I found the problem but am still unsure how to fix it - the string in the database has odd question mark black symbols - how can I remove them/unformat the string? "�1�4�0�0� �W� �W�E�S�T� �L�P� �S� �7�0�0� �P�O�S�T� �O�A�K� �B�L�V�D��" Quote Link to comment Share on other sites More sharing options...
Solution kernelgpf Posted August 13, 2013 Author Solution Share Posted August 13, 2013 Just ended up doing a preg_replace. 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.