Re: Foreign Characters Break in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Op 1/22/10 2:28 AM, Ryan Park schreef:
> Forgot to reply all.
> 
> You can see that it's in the middle of the sql statement.
> It looks fine here but some how it breaks during the query.
> 
> <?php
> mysql_connect("localhost", "adminID", "password") or die(mysql_error());
> echo "Connected to MySQL<br />";
> 
> mysql_select_db("databasename") or die(mysql_error());
> echo "Connected to Database<br />";
> 
> $sql = "INSERT INTO xe_modules (module_srl, module, module_category_srl,
> layout_srl, menu_srl, site_srl, mid, skin, browser_title, description,
> is_default, content, open_rss, header_text, footer_text, regdate) VALUES
> ('135', 'bodex', '0', '53', '0', '0', 'free', 'xe_default', '자유게시판
> ', '', 'N', '', 'Y', '', '', UNIX_TIMESTAMP());";

you need to:

1. have some understanding of char encoding and character sets.
2. define you DB[tables] to use a collation that supports the stuff you want to enter.
3. you need to connect to the DB with a suitable charset (google 'SET NAMES')
4. you need to make sure the data you are putting into your queries is in that same charset.

basically you need UTF8 - be prepared for some pain and a lot of reading in order
to get to grips with these concepts, I've personally found that encoding, charsets et al
are not the easiest things to one's head round.

> 
> mysql_query($sql) or die(mysql_error());
> 
> mysql_close();
> ?>
> 
> On 1/21/2010 5:19 PM, Jim Lucas wrote:
>> Ryan Park wrote:
>>   
>>> Hello I'm currently trying to use PHP to insert foreign characters
>>> into one of the mysql database tables.mysql_query() worked
>>> seamlessly, but when I check the inserted data on phpMyAdmin it shows
>>> the foreign characters in broken letters, like this ì‹œíŒ<-
>>> jibberish...The foreign characters show fine when I'm typing it out
>>> on my editor to code PHP, but it gets broken into unrecognizable
>>> symbols when put into mysql database columns.
>>> I tried to create the same thing this time through phpMyAdmin console
>>> and it worked great, the foreign characters showed correctly as they
>>> should.The column that I'm trying to put the foreign characters into
>>> is set as utf8_general_ci.I wish to use PHP to insert the data into
>>> the database because I'll be inserting massive amounts of them at
>>> once, so I just can't continue with this problem at hand.
>>> I'll greatly appreciate any help, thank you.                        
>>> _________________________________________________________________
>>> Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
>>> http://clk.atdmt.com/GBL/go/196390709/direct/01/
>>>      
>> How about showing a little of the insert code.  ie: how you are
>> gathering the
>> data, how you are preping the data, and the actual insert statement.
>>
>>    
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux