Solved

PHP/MySQL Export Data from Recordset; Foreign Characters

Posted on 2011-03-14
1
356 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 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