0

So i'm building an app for Shopify. Because of the way Shopify works, we annoyingly have to deal with vendors by name, rather than having a numeric uid.

This has posed some problems for us. We have a vendor that was imported into our database from Shopify as "Colección Luna". Doing the following works fine:

SELECT email FROM vendors WHERE name=('Colección Luna') LIMIT 1

This returns the data that we are looking for. However, in php, if we do something like this:

$row = mysql_fetch_row(mysql_query("SELECT name FROM vendors WHERE name=('Colección Luna') LIMIT 1"));

echo $row[0];

This will output:

Colecciu00f3n Luna

This is a problem, because we use the vendor name as our uid in all cases that we are dealing with them. Using the name that we get from the database to find the email for example would cause our sql statement to look like this:

SELECT email FROM vendors WHERE name=('Colecciu00f3n Luna') LIMIT 1

Which ultimately doesn't find the data that we're looking for because of the difference in characters.

I assume that php is encoding its strings in utf-8 by default, is there a way that I can force it to output its strings in the same format as the database?

Many thanks in advance.

Donny Sutherland
  • 346
  • 2
  • 3
  • 14
  • Your encoding handling is screwed up. You need to fix your database and PHP-to-MySQL encoding handling to deal with characters in their correct form. "ó" is *not* the character you're looking for (*hand swipe*). – deceze Apr 15 '14 at 13:30
  • Hmm, that makes alot of sense actually. Could you possibly do a quick example of how I could correctly handle the encoding between taking the data from shopify and storing it in our database? – Donny Sutherland Apr 15 '14 at 13:34
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through), [strange character encoding of stored data , old script is showing them fine new one doesn't](http://stackoverflow.com/questions/20237474/strange-character-encoding-of-stored-data-old-script-is-showing-them-fine-new) - see these two – deceze Apr 15 '14 at 13:35

0 Answers0