Jump to content

Storing International Characters through PHP


TOgakangaroo

Recommended Posts

Hello, I am working on a large project which involves among other things storing names with international characters in MySQL tables.  This data is typically delivered via spreadsheets so I have written a utility to do upload a file and do just that.  I am running into the problem currently that certain characters (i.e. the spanish e with an accent) will not import correctly causing the rest of the name to be cut off.

So for example, running
$term =  'México';
mysql($database_info, "INSERT INTO tblSomeTable VALUES $term");
will store only 'M'.

If I hardwire the term into the query
mysql($database_info, "INSERT INTO tblSomeTable VALUES 'México'");
It doesn't cut off but does insert gibberish

One intersting thing that I've found is that everything works out fine when the variable is passed through the HTTP Post Method
mysql($database_info, "INSERT INTO tblSomeTable VALUES $_POST['name']");
where $_POST["name"]='México' from a form imput
this inserts correctly.

My intuition is that I need to set PHP to use the same encoding that HTTP POST uses but I don't know  if that's true nor exactly how to do that.  Has anybody run into this problem before/can help me out?
Thanks a lot for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.