Désolée, voici les codes ci-dessous.
Autre chose, peut-être une piste : je n'avais pas accès au fichier error.log, j'ai résolu le problème. J'ai refait des essais je vois 3 erreurs :
Pour la 1ère : je ne comprends pas, j'ai tout vérifié et ne vois pas d'anomalie ?Citation:
[Fri Feb 28 14:13:04.594018 2020] [proxy_fcgi:error] [pid 5518] [client 78.203.140.190:53770] AH01071: Got error 'PHP message: PHP Warning: include_once(./include/fonctions.inc.php): failed to open stream: No such file or directory in /public_html/trait_rech_corps.php on line 6PHP message: PHP Warning: include_once(): Failed opening './include/fonctions.inc.php' for inclusion (include_path='.:/usr/share/php') in /public_html/trait_rech_corps.php on line 6', referer: ...
[Fri Feb 28 14:13:04.594794 2020] [proxy_fcgi:error] [pid 5518] [client 78.203.140.190:53770] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function create_export_data_to_csv() in /public_html/trait_rech_corps.php:139\nStack trace:\n#0 {main}\n thrown in /public_html/trait_rech_corps.php on line 139', referer: ...
[Fri Feb 28 14:13:09.052035 2020] [proxy_fcgi:error] [pid 5466] [client 78.203.140.190:53777] AH01071: Got error 'PHP message: PHP Warning: file_get_contents(csv/export_csv.csv): failed to open stream: No such file or directory in /public_html/fichier_csv.php on line 12', referer: ...
Pour la 2ème : ligne 139 c'est la ligne d'appel de la fonction : create_export_data_to_csv($donnees_all); ?
Pour la 3ème : ?
Un grand merci de prendre le temps de regarder mes codes.
Evelyne
fonction_inc.php
fichier_csv.phpCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 <?php /** * Exports an associative array into a CSV file using PHP. * * @see https://stackoverflow.com/questions/21988581/write-utf-8-characters-to-file-with-fputcsv-in-php * * @param array $datas The table you want to export in CSV * @param string $filename The name of the file you want to export (WITH extension) * @param string $delimiter The CSV delimiter you wish to use. The default ";" is used for a compatibility with microsoft excel * @param string $enclosure The type of enclosure used in the CSV file, by default it will be a quote " */ function create_export_data_to_csv($datas,$filename='export_csv',$delimiter = ';',$enclosure = '"') { // Attention : $filename est ici indiqué SANS extension '.csv' // répertoire où enregistrer le fichier $csv_rep = 'csv/'; // Le dossier s'appelle ici "csv" (à toi de mettre le bon chemin) // Ouverture du fichier $fp = fopen($csv_rep.$filename.'.csv', 'w'); // on rajoute ici l'extension '.csv' // Si le fichier a vocation a être importé dans Excel, // pour corriger les problèmes d'affichage des caractères internationaux (les accents par exemple) // Insert the UTF-8 BOM in the file fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) )); // Ligne d'entête : titres des colonnes fputcsv($fp,array_keys($datas[0]),$delimiter,$enclosure); // Ajout ligne à ligne des données foreach ($datas as $fields) { fputcsv($fp, $fields,$delimiter,$enclosure); } // Fermeture du fichier fclose($fp); } ?>
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13 <?php error_reporting(E_ALL); // en TEST !! $filename = urldecode($_GET['filename']); // nom du fichier, SANS extension $csv_rep = 'csv/'; // Le dossier s'appelle ici "csv" (à toi de mettre le bon chemin) // Tells to the browser that a file is returned, with its name : $filename.csv header("Content-disposition: attachment; filename=$filename.csv"); // Tells to the browser that the content is a csv file header("Content-Type: text/csv"); file_get_contents($csv_rep.$filename.'.csv'); ?>