sungpeng Posted April 11, 2009 Share Posted April 11, 2009 <?php if($_POST[action]=="Submit") { include ("".$_SERVER['DOCUMENT_ROOT']."/housing/includes/config.php"); $loginname=$_POST["loginname"]; $insert_student=mysql_query("insert into users (loginname) values ('$loginname'"); ?> }else{ ?> <html> <head> <title></title> </head> <body> <table width="400" align="center"> <br> <form name="form" action="<?php echo "$PHP_SELF"; ?>" method="post"> <tr> <td width="35%">Loginname</td> <td><input type="text" name="loginname" size="25"></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" name="action" value="Submit"></td> </tr> </table> </form> </body> </html> <?php } ?> Hi checking when I input chinese character into "loginname" field using the above code. The chinese character turn out not able to read. Is there a special code for input chinese character? Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/ Share on other sites More sharing options...
WolfRage Posted April 11, 2009 Share Posted April 11, 2009 What kind of encoding are you using for the database and the connection to that database? What encoding are the individual tables? If you are not using UTF-8 it may not be supported. Note: that UTF-8 does not yet support the full implementation of standard chinese characters. Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807145 Share on other sites More sharing options...
sungpeng Posted April 11, 2009 Author Share Posted April 11, 2009 <? $hostname = "localhost"; $username = "hello"; $password = "fefa"; $dbName = "sgfai_property"; MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database"); mysql_select_db("$dbName") or die("Unable to select database"); ?> like say I need to insert this 级搜索 into mysql, it will turn out character that cannot read. Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807196 Share on other sites More sharing options...
sungpeng Posted April 11, 2009 Author Share Posted April 11, 2009 $result = mysql_query("SELECT * FROM comlistings) or die ("Query failed"); while ($row = mysql_fetch_array($result)) { $district=$row[district]; echo "$row[district]"; } My data retrieve is normal one Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807199 Share on other sites More sharing options...
ToonMariner Posted April 11, 2009 Share Posted April 11, 2009 your database needs to support the character set - utf-8 is the best all round solution. Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807202 Share on other sites More sharing options...
sungpeng Posted April 11, 2009 Author Share Posted April 11, 2009 ya my database is UTf-8. but if my window xp don't set to chinese languages PRC. it cannot view character from the database. Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807225 Share on other sites More sharing options...
Spikerok Posted April 11, 2009 Share Posted April 11, 2009 <?php if($_POST[action]=="Submit") { include ("".$_SERVER['DOCUMENT_ROOT']."/housing/includes/config.php"); $loginname=$_POST["loginname"]; $insert_student=mysql_query("insert into users (loginname) values ('$loginname'"); ?> }else{ ?> <html> <head> <title></title> </head> <body> <table width="400" align="center"> <br> <form name="form" action="<?php echo "$PHP_SELF"; ?>" method="post"> <tr> <td width="35%">Loginname</td> <td><input type="text" name="loginname" size="25"></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" name="action" value="Submit"></td> </tr> </table> </form> </body> </html> <?php } ?> Hi checking when I input chinese character into "loginname" field using the above code. The chinese character turn out not able to read. Is there a special code for input chinese character? hi, you might want to read this: http://www.tanzilo.com/2008/10/13/php-mysql-unicode-solution-to-chinese-russian-or-any-language/ you will see that you have to make those char encoding queries before inserting things in the database mysql_query("SET character_set_client=utf8", $dbLink); mysql_query("SET character_set_connection=utf8", $dbLink); you can change utf8 on any other char set you want hope this helps Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807232 Share on other sites More sharing options...
sungpeng Posted April 11, 2009 Author Share Posted April 11, 2009 ok I tried to do according to the above, now even my window xp set to chinese PRC also cannot view.. All I get is ??? Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807274 Share on other sites More sharing options...
sungpeng Posted April 11, 2009 Author Share Posted April 11, 2009 echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"; mysql_query("SET character_set_client=utf8", $dbLink); mysql_query("SET character_set_connection=utf8", $dbLink); $update_pdt=mysql_query("update instructor set description='$_POST[description]' where pid=$_GET[pid]", $dbLink); Link to comment https://forums.phpfreaks.com/topic/153593-solved-input-chinese-character-into-mysql/#findComment-807283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.