Précédent   Forum des professionnels en informatique > PHP > Langage
Langage Forum sur le langage PHP, la POO, les conventions, la sécurité, etc. Avant de poster : FAQ Langage, toutes les FAQ PHP, cours langage et sources PHP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/12/2011, 15h49   #1
Invité de passage
 
Homme
Webmaster
Inscription : décembre 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Webmaster

Informations forums :
Inscription : décembre 2011
Messages : 2
Points : 1
Points : 1
Par défaut Problème après encodage URL

Bonjour,

Bon voilà, j'ai besoin de votre aide.

Après l'encodage des caractères des URL, je me retrouve avec un autre problème.

Exemple:

A la place de

Code :
 : Accueil :: Catégorie :: Matériel Informatique ::
Je me retrouve avec

Code :
accueil :: categorie :: materiel-informatique ::
C'est encodée comme les URL monsite.com/materiel-informatique.html

Codes sources

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function EdURL($uttl) {
 
// Définition du séparateur
if(!defined("SEPARATOR"))
define("SEPARATOR", "-");
 
$tofind = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ"; // Lettre accentuées
$replac = "aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyyby"; // Equivalant non accentué
 
// Mise en minuscule + suppression des lettres accentuées par leur équivalant non accentué
$uttl = strtr(strtolower($uttl),$tofind,$replac);
 
// Remplacement de caractère non alphanumérique par un séparateur
$uttl = ereg_replace("[^a-z0-9]", SEPARATOR, $uttl);
 
// Suppression des doubles séparateurs
while (strstr($uttl, SEPARATOR . SEPARATOR))
$uttl = str_replace(SEPARATOR . SEPARATOR, SEPARATOR, $uttl);
 
// Retour avec suppression d’un possible séparateur en fin de chaîne
return(ereg_replace(SEPARATOR . "$", "", $uttl));
Code :
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
//---------------------->
 
$CATEGORIES = CATEGORIES;
$table1 = "$CATEGORIES";
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$category'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t1 = "$row[TITLE]";
$i1 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t2 = "$row[TITLE]";
$i2 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t3 = "$row[TITLE]";
$i3 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t4 = "$row[TITLE]";
$i4 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t5 = "$row[TITLE]";
$i5 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t6 = "$row[TITLE]";
$i6 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t7 = "$row[TITLE]";
$i7 = $row[ID];
 
//---------->
 
$SQL = "SELECT * from $table1 WHERE ID = '$row[CATEGORY]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$t8 = "$row[TITLE]";
$i8 = $row[ID];
 
//---------->
 
if ($mr != Enabled || $setpage == categories) {
 
echo "<a href=\"?page=$catpage\">Top</a> :: ";
 
if (empty($t8)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i8\">$t8</a> :: ";
if (empty($t7)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i7\">$t7</a> :: ";
if (empty($t6)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i6\">$t6</a> :: ";
if (empty($t5)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i5\">$t5</a> :: ";
if (empty($t4)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i4\">$t4</a> :: ";
if (empty($t3)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i3\">$t3</a> :: ";
if (empty($t2)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i2\">$t2</a> :: ";
if (empty($t1)) {} else echo "<a href=\"?page=$setpage&$getvariable=$i1\">$t1</a> :: ";
 
} else {
 
 
$t1=EdURL($t1);
$t2=EdURL($t2);
$t3=EdURL($t3);
$t4=EdURL($t4);
$t5=EdURL($t5);
$t6=EdURL($t6);
$t7=EdURL($t7);
$t8=EdURL($t8);
 
 
echo "<a href=\"index.php\">Accueil</a> :: ";
 
if (empty($t8)) {} else echo "<a href=\"categorie-$t8-$i8.html\">$t8</a> :: ";
if (empty($t7)) {} else echo "<a href=\"categorie-$t7-$i7.html\">$t7</a> :: ";
if (empty($t6)) {} else echo "<a href=\"categorie-$t6-$i6.html\">$t6</a> :: ";
if (empty($t5)) {} else echo "<a href=\"categorie-$t5-$i5.html\">$t5</a> :: ";
if (empty($t4)) {} else echo "<a href=\"categorie-$t4-$i4.html\">$t4</a> :: ";
if (empty($t3)) {} else echo "<a href=\"categorie-$t3-$i3.html\">$t3</a> :: ";
if (empty($t2)) {} else echo "<a href=\"categorie-$t2-$i2.html\">$t2</a> :: ";
if (empty($t1)) {} else echo "<a href=\"categorie-$t1-$i1.html\">$t1</a> :: ";
 
}
Merci d'avance pour votre aide.
gooffy est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/12/2011, 16h17   #2
Rédacteur
 
Avatar de jreaux62
 
Homme Jérôme Réaux
Webdesigner
Inscription : août 2008
Messages : 2 994
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Réaux
Âge : 45
Localisation : France, Pas de Calais (Nord Pas de Calais)

Informations professionnelles :
Activité : Webdesigner
Secteur : Arts - Culture

Informations forums :
Inscription : août 2008
Messages : 2 994
Points : 5 787
Points : 5 787
Envoyer un message via Skype™ à jreaux62
C'est normal, vu ton utilisation de la fonction...
Remplace :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$t1=EdURL($t1);
$t2=EdURL($t2);
$t3=EdURL($t3);
$t4=EdURL($t4);
$t5=EdURL($t5);
$t6=EdURL($t6);
$t7=EdURL($t7);
$t8=EdURL($t8);
 
echo "<a href=\"index.php\">Accueil</a> :: ";
 
if (empty($t8)) {} else echo "<a href=\"categorie-$t8-$i8.html\">$t8</a> :: ";
if (empty($t7)) {} else echo "<a href=\"categorie-$t7-$i7.html\">$t7</a> :: ";
if (empty($t6)) {} else echo "<a href=\"categorie-$t6-$i6.html\">$t6</a> :: ";
if (empty($t5)) {} else echo "<a href=\"categorie-$t5-$i5.html\">$t5</a> :: ";
if (empty($t4)) {} else echo "<a href=\"categorie-$t4-$i4.html\">$t4</a> :: ";
if (empty($t3)) {} else echo "<a href=\"categorie-$t3-$i3.html\">$t3</a> :: ";
if (empty($t2)) {} else echo "<a href=\"categorie-$t2-$i2.html\">$t2</a> :: ";
if (empty($t1)) {} else echo "<a href=\"categorie-$t1-$i1.html\">$t1</a> :: ";
par :
Code :
1
2
3
4
5
6
7
8
9
10
echo "<a href=\"index.php\">Accueil</a> :: ";
 
if (empty($t8)) {} else echo "<a href=\"categorie-".EdURL($t8)."-$i8.html\">$t8</a> :: ";
if (empty($t7)) {} else echo "<a href=\"categorie-".EdURL($t7)."-$i7.html\">$t7</a> :: ";
if (empty($t6)) {} else echo "<a href=\"categorie-".EdURL($t6)."-$i6.html\">$t6</a> :: ";
if (empty($t5)) {} else echo "<a href=\"categorie-".EdURL($t5)."-$i5.html\">$t5</a> :: ";
if (empty($t4)) {} else echo "<a href=\"categorie-".EdURL($t4)."-$i4.html\">$t4</a> :: ";
if (empty($t3)) {} else echo "<a href=\"categorie-".EdURL($t3)."-$i3.html\">$t3</a> :: ";
if (empty($t2)) {} else echo "<a href=\"categorie-".EdURL($t2)."-$i2.html\">$t2</a> :: ";
if (empty($t1)) {} else echo "<a href=\"categorie-".EdURL($t1)."-$i1.html\">$t1</a> :: ";
ou plus judicieusement :
Code :
1
2
3
4
5
6
7
8
9
10
echo "<a href=\"index.php\">Accueil</a> :: ";
 
if (!empty($t8)) echo "<a href=\"categorie-".EdURL($t8)."-$i8.html\">$t8</a> :: ";
if (!empty($t7)) echo "<a href=\"categorie-".EdURL($t7)."-$i7.html\">$t7</a> :: ";
if (!empty($t6)) echo "<a href=\"categorie-".EdURL($t6)."-$i6.html\">$t6</a> :: ";
if (!empty($t5)) echo "<a href=\"categorie-".EdURL($t5)."-$i5.html\">$t5</a> :: ";
if (!empty($t4)) echo "<a href=\"categorie-".EdURL($t4)."-$i4.html\">$t4</a> :: ";
if (!empty($t3)) echo "<a href=\"categorie-".EdURL($t3)."-$i3.html\">$t3</a> :: ";
if (!empty($t2)) echo "<a href=\"categorie-".EdURL($t2)."-$i2.html\">$t2</a> :: ";
if (!empty($t1)) echo "<a href=\"categorie-".EdURL($t1)."-$i1.html\">$t1</a> :: ";
ou encore (plus condensé) :
Code :
1
2
3
4
5
echo "<a href=\"index.php\">Accueil</a> :: ";
 
for($n=8; $n>0; $n--){
	if (!empty(${'t'.$n})) echo "<a href=\"categorie-".EdURL(${'t'.$n})."-".${'i'.$n}.".html\">".${'t'.$n}."</a> :: ";
}
__________________
"Ce qui se conçoit bien s'énonce clairement - Et les mots pour le dire arrivent aisément."
Nicolas Boileau-Despréaux, Homme de lettres français (1636-1711), principal théoricien de l'esthétique classique.
Site perso Mes tutos DVP : Gestion-Affichage de Nouvelles - Affichage en tableau HTML - Fonctions de redimensionnement d'images
jreaux62 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/12/2011, 16h27   #3
Invité de passage
 
Homme
Webmaster
Inscription : décembre 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Webmaster

Informations forums :
Inscription : décembre 2011
Messages : 2
Points : 1
Points : 1
Un grand merci jreaux62, je commençais à m'arracher les cheveux
gooffy est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h50.


 
 
 
 
Partenaires

Hébergement Web