View Single Post
ישן 12-04-15, 00:48   # 1
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

יצירת קובץ csv עם עבברית

יש לי את הקוד הזה:

PHP קוד:
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');

// create a file pointer connected to the output stream
$output fopen('php://output''w');

// output the column headings
fputcsv($output, array('שדה 1''שדה 2''שדה 3'));

include(
'config.php');
$id 2;
$sql "SELECT name FROM shoes WHERE event_id = '$id'";
$result mysqli_query($connection,$sql);

// loop over the rows, outputting them
while ($row mysqli_fetch_assoc($result)) fputcsv($output$row); 
השורה של "שדה1 וכ'ו אני מקבל מעולה..בעברית.
את השורה של הנתונים שאמורים לצאת מהמסד אני מקבל ככה:
"׳“׳•׳¨ ׳‘׳

קובץ הconfig שלי:

PHP קוד:
defined('DB_HOST')? null define('DB_HOST''localhost');
defined('DB_USER')?  null define('DB_USER''***');
defined('DB_PASS')?  null define('DB_PASS''***');
defined('DB_NAME')?  null define('DB_NAME''***');

$connection mysqli_connect(DB_HOST ,DB_USER ,DB_PASS ,DB_NAME);

if (
mysqli_connect_errno($connection)){
    echo 
"Failed to connect to MySQL: " mysqli_connect_error();
    die();
}

mysqli_set_charset($connection"utf8"); 
כמו שאתם רואים הוא מכיל mysqli_set_charset
המסד + הטבלאות + השדות מקודדים utf8_general_ci

מישהו יודע מה הבעיה? הדף מקודד utf-8...גם עובדה שהשורה הקבועה יוצאת בעברית..

אשמח לעזרה..תודה.
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote