giunz Posted May 25, 2009 Share Posted May 25, 2009 Hello everyone. I want to export the data of a table as csv.The problem is that the table contains greek characters and when I try to export them with php in a csv file, the output file displays the greek chars as ? even in the notepad.The webpage charset is set to utf8,the same as the db's (utf8_bin). The sql export of the table i need to export in csv this one: -- phpMyAdmin SQL Dump -- version 3.1.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: May 25, 2009 at 11:17 AM -- Server version: 5.1.30 -- PHP Version: 5.2.8 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `unipi` -- -- -------------------------------------------------------- -- -- Table structure for table `contact` -- CREATE TABLE IF NOT EXISTS `contact` ( `contactId` bigint(255) NOT NULL AUTO_INCREMENT, `contactName` varchar(255) COLLATE utf8_bin NOT NULL, `contactSurname` varchar(255) COLLATE utf8_bin NOT NULL, `contactPhone` varchar(255) COLLATE utf8_bin NOT NULL, `contactEmail` varchar(255) COLLATE utf8_bin NOT NULL, `contactTitle` varchar(255) COLLATE utf8_bin NOT NULL, `contactOrgId` bigint(255) NOT NULL, PRIMARY KEY (`contactId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC AUTO_INCREMENT=4 ; -- -- Dumping data for table `contact` -- INSERT INTO `contact` (`contactId`, `contactName`, `contactSurname`, `contactPhone`, `contactEmail`, `contactTitle`, `contactOrgId`) VALUES (1, 'Σοφοκλης', 'Σοφοκλεους', '210666666', 'afentiko@palati.gr', 'Κος', 1), (2, 'Νικος', 'Νικολαου', '2106666666', 'nikolaou@nikos.com', 'Κος', 2), (3, 'Δειγμας', 'Παρασκευάς', '2109999999', 'example@example.com', 'Mr', 3); I have also added the php which has the export code similar to : http://www.phpsimple.net/tutorials/mysql_to_csv/ Thank you [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/ Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted May 25, 2009 Share Posted May 25, 2009 header("Content-type: application/csv;chartset=utf-8"); chartset ? Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/#findComment-841885 Share on other sites More sharing options...
giunz Posted May 25, 2009 Author Share Posted May 25, 2009 Fixed that but the problem remains. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/#findComment-841949 Share on other sites More sharing options...
giunz Posted June 1, 2009 Author Share Posted June 1, 2009 Can't anyone please help?I keep searching but I can not find a solution Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/#findComment-846743 Share on other sites More sharing options...
fenway Posted June 6, 2009 Share Posted June 6, 2009 A whole lot of things need to be set to UTF-8 correctly... php, mysql, and whatever editor you're using. Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/#findComment-850497 Share on other sites More sharing options...
michael624 Posted June 6, 2009 Share Posted June 6, 2009 the data is in 2byte format for special characters. notepad reads one byte characters, unless you file-saveas and click encding type as utf8. Have you tried putting it into excel and seeing what happens? I think when you save the csv file as UTF8 the headers in the file will be recoognized by excel then it will work. Quote Link to comment https://forums.phpfreaks.com/topic/159581-export-mysql-table-as-csv-for-msexcel/#findComment-850604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.