So I have a function that gets some string variables from a form (after the form is submitted), then runs a query using those variables and returns lines of results. I have several conditions that work fine, except for one and I can't figure out what's wrong. When I print out the query and run it in phpMyadmin - it works just fine (returns 3 rows for example), but it doesn't run on the page (shows that 0 rwos are returned). One thing that I have noticed is that when I do var_dump it gives the correct type (string) but wrong length. trim doesn't make any difference. So fo example
$name2 = "John Doe";
var_dump($name1);
var_dump($name2);
The name2 returns string(8) But when for name1 it returns string(9), even though name1 is also "John Doe" - I have no idea what that extra character is. That variable is coming from a form, from a select element. Select is populated from a table. I trim resulting POST value before assigning to name1. Character encoding is the same for the table where names in select element are coming from and table on which I run a query. All other variables from the form are passing fine and query runs correctly if I don't add the name. Again, if I print out the query (with name condition included) and copy and paste into phpMyAdmin - it runs just fine. I'm going crazy here.