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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.