Bonjour,
J'ai développé une google map où s'affichent différents marqueurs provenant d'une base SQL (cf http://code.google.com/intl/fr/apis/...qlajax_v3.html)
Le pb provient des caractères spéciaux qui ne s'affichent pas correctement.
http://chti.sportif.free.fr/calendrier_sports.php
J'ai trouvé une solution temporaire de dépannage en encodant moi-même tous les caractères spéciaux de mon fichier .CSV mais c'est bien sûr peu pratique
Mon fichier .csv pour l'import des données dans MySQL avec un exemple
le fichier .php qui recupère les infos de la table
Code : Sélectionner tout - Visualiser dans une fenêtre à part 13 février 2011,puce_rouge.png,co,50.64227621899096,3.0030441284179688,LOMME,O² Régionale LNPCO,CO régionale Sprint,http://www.opale-orientation.com/,test.htm,http://chti.sportif.free.fr/fiche_de_course.htm,
Comment résoudre ce pb pour que je puisse écrire normalement dans mon fichier .CSV ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 <?php require("./phpsqlajax_dbinfo.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('<','<',$htmlStr); $xmlStr=str_replace('>','>',$xmlStr); $xmlStr=str_replace('"','"',$xmlStr); $xmlStr=str_replace("'",''',$xmlStr); $xmlStr=str_replace("&",'&',$xmlStr); return $xmlStr; } // Opens a connection to a mySQL server $connection=mysql_connect (localhost, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active mySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM markers_calendrier WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'date="' . parseToXML($row['date']) . '" '; echo 'puce="' . parseToXML($row['puce']) . '" '; echo 'category="' . parseToXML($row['category']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'ville="' . parseToXML($row['ville']) . '" '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'info="' . parseToXML($row['info']) . '" '; echo 'link="' . parseToXML($row['link']) . '" '; echo 'fiche="' . parseToXML($row['fiche']) . '" '; echo 'infoUrl="' . parseToXML($row['infoUrl']) . '" '; echo 'photo="' . parseToXML($row['photo']) . '" '; echo '/>'; } // End XML file echo '</markers>'; ?>
Encodage des pages (ANSI, UTF8.. ?.), import du fichier .csv, charset.... ?
http://us2.php.net/manual/fr/function.utf8-encode.php
Je n'y connais rien en php. Que dois je faire ?Using PHP's echo to output XML
If you don't have access to PHP's dom_xml functions, then you can simply output the XML with the echo function. When using just the echo function, you'll need to use a helper function (e.g. parseToXML) that will correctly encode a few special entities (<,>,",') to be XML friendly.
In the PHP, first connect to the database and execute the SELECT * (select all) query on the markers table. Then echo out the parent markers node, and iterate through the query results. For each row in the table (each location), you need to echo out the XML node for that marker, sending the name and address fields through the parseToXML function first in case there are any special entities in them. Finish the script by echoing out the closing markers tag.
Note: If your database contains international characters or you otherwise need to force UTF-8 output, you can use utf8_encode on the outputted data.
merci
Partager