Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL - insert japanese from PHP - Encoding Troubles
    primarykey
    data
    text
    <p>I'm trying to insert some japanese words in a mysql table! If I insert 'こんにちは' using phpMyAdmin, the word is displayed fine from phpMyAdmin. But if I try to insert it through php, as follow:</p> <pre><code>mysql_connect($Host, $User, $Password); mysql_select_db($Database); $qry = "INSERT INTO table VALUES (0 , 'こんにちは')"; echo mysql_query($qry); </code></pre> <p>In phpMyAdmin i see "ã“ã‚“ã«ã¡ã¯" ... why?</p> <p>And if I try to fetch from the database:</p> <pre><code>$arr = mysql_fetch_array(mysql_query("SELECT * FROM table where id = 1")); echo $arr[1]; </code></pre> <p>The browser shows nothing!!!</p> <p>How can I solve?</p> <p>Thank you in advance for your help!!!</p> <hr> <p><strong>~EDIT~</strong></p> <p>My database collation is setup to utf8_general_ci</p> <hr> <p><strong>~EDIT 2~</strong></p> <p>I don't need to display the output on an HTML page, but the japanese words are printed on a XML page whose encoding is setup to UTF-8.</p> <pre><code>$plist = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n"; $plist .= "&lt;!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"&gt;\n"; $plist .= "&lt;plist version=\"1.0\"&gt;\n"; $plist .= "&lt;array&gt;\n"; $plist .= "\t&lt;dict&gt;\n"; $plist .= "\t\t&lt;key&gt;test&lt;/key&gt;\n"; $plist .= "\t\t&lt;string&gt;".$arr[1]."&lt;/string&gt;\n"; $plist .= "\t&lt;/dict&gt;\n"; $plist .= "&lt;/array&gt;\n"; $plist .= "&lt;/plist&gt;"; echo $plist; </code></pre> <p>the output of this code is:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;test&lt;/key&gt; &lt;string&gt;&lt;/string&gt; &lt;/dict&gt; &lt;/array&gt; &lt;/plist&gt; </code></pre> <p>So, there is no value for the key "test" ... what can I do? Thanks! </p> <hr> <p><strong>~ SOLVED ~</strong></p> <p>Problems solved using the function mysql_set_charset() after connecting to the database!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload