web_master Posted January 5, 2009 Share Posted January 5, 2009 Hi, I got a problem, how can I save an utf-8 txt into Unicode txt file same time when I sent it to dBase. I connect to dBase like this: <?php mysql_connect("localhost","root","") or die("Can’t connect to SQL server"); mysql_select_db("dbase") or die("Can’t connect to DataBase"); mysql_query("SET NAMES 'utf8'"); mysql_query('SET CHARACTER SET utf8'); ?> than I sent the text into dBase: <?php $query = mysql_query("INSERT INTO `text_table` (`text`) VALUES (' ".$_POST['text']." ') "); ?> So, I use a utf-8 charset, and I want to when the "text" go into dbase to go into one txt-file to with a Unicode characterset. thanx Link to comment https://forums.phpfreaks.com/topic/139539-save-as-unicode-txt-file/ Share on other sites More sharing options...
Absorbator Posted January 6, 2009 Share Posted January 6, 2009 I think you just have to translate your data into utf-8 string like: <?php $theText = utf8_encode($_POST['text']); $query = mysql_query("INSERT INTO `text_table` (`text`) VALUES (' $theText ') "); $fileHandle = fopen("file.txt", "wb"); fwrite($fileHandle, $theText); fclose($fileHandle); ?> ---------------- Now playing: D-Phrag - Deep Transmissions Part 3 via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/139539-save-as-unicode-txt-file/#findComment-731039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.