2017-02-14

The Question

Why the heck is this query failing?

Debugging suggestions welcome

I currently suspect the main sites form of doing something underhanded but am not sure how or what to check. Don't let that stop anyone from suggesting an alternative culpret.

The Weirdness

I have a MySQL database that I am hitting with a prepared statement via PHP-PDO.

I am doing essentially the same thing from two different parts of the application (one an older admit site, and the other, a newer main site)

Same hosting, same server, same account. Both send a last name (amongst other fields) via form submission method=post

That value is then bound via PHP/POD and then send as a query to a MySQL database (same one in each case).

The admin site returns queried apostrophe'd names just fine!

The main site does not when the variable is POSTed via a form, and has an apostrophe.

It will return fine when cutting and pasting the name (with apostrophe) into the code.

That same value, which has just literally worked when hard coded, fails without errors, when put into the form.

The code below is present on the newer main site (fails) verbatim

The code below when copied verbatim into the older admin site will still work.

The PDO methodology is exactly the same, as far as I can see.

Both pages are UTF-8

Both show no differences that i see in headers or form data from inspection pane.

Cutting and pasting an apostrophe'd values from any situation to any other situation will work everywhere except when pasted into the form on the main site.

The Code:

The Output from Admin site (works):

The Output Main site (fails):

Musings:

Table is encoded as latin swedish or some damned thing in order to solve some problem I've completely forgotten the details to about 10 years ago.
-cut&paste of name from failed attempt in PHPMyAdmin works fine.

Both scripts are UTF-8 although they get that encoding in different fashions.

New main site (fails) is HTML5

Old admin site (succeeds) is XHTML

The problem site (main) WILL return an apostrophe'd name if simply given the "O" for example, as designed via the LIKE % operator

Show more