Solved

PHP/MySQL Export Data from Recordset; Foreign Characters

Posted on 2011-03-14
1
357 Views
Last Modified: 2012-05-11
PHP exports MySQL data to .csv files without problem except in the cae of accented characters. MySQL and PHP are set to utf8 and the data displays correctly on the page.

Is there any way we can improve the downloads?
0
Comment
Question by:smudgemouse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
brb6708 earned 500 total points
ID: 35128843
<?php

$dblink = new mysqli($servername,$user,$password,$dbname);

$res = $dblink->query("SET CHARACTER SET utf8");
$res = $dblink->query("SET NAMES utf8");
?>


after this you have made sure that mysql only talks utf8 to php. You can replace utf8 to any known character set compiled in MySQL if you like.

But I do not understand why you use php to convert MySQL tables to csv files. You can do it by a simple MySQL query in any character sert you like.


0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question