Bonjour, suite au transfert de mon vieux site vers un nouveau serveur, j'aimerai corriger les "php notice" des error_log. Au début il me disait d ajouter des guillemets dans mes variables pour changer par exemple les $_GET[s] en $_GET['s'].
Maintenant il m'indique que les variables ne sont pas initialisées en affichant "php notice: Undefined index: s in... "
Donc je découvre pour la première fois l'utilisation des isset. J'ai compris leur utilisation mais je suis pas assez calé encore pour les intégrer à mes pages en les rédigeant proprement pour chaque ligne de variables, d'autant qu'il y a souvent 2 variables non initialisées. Ce sont des vieux codes manipulés précédemment de différents programmeur. Maintenant je suis seul à m'occuper de mon site donc soyez indulgent, j'apprends en même temps que je refais mon site. Quelqu'un aurait il la gentillesse de m'aider à rédiger ça ?
La page index.php dont les variables ne sont pas initialisées :
et navigation_mois.inc.php dont les variables "o" et "s" ne sont pas initialisées:
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
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
95
96
97
98
99
100
101
102
103
104
105 <? require ("news_config.inc.php"); $niveau=1; require ("../" . INCLUDEDIR . "/protection.inc.php"); require ("../" . INCLUDEDIR . "/format.inc.php"); require ("../" . INCLUDEDIR . "/date.inc.php"); ?> <html> <head> <title><? echo $lang[0]; ?></title> </head> <body onContextMenu="return false"> <form name="form" method="post" action=""> <link href="../style.css" rel="stylesheet" type="text/css"> <link href="../style_inputtext.css" rel="stylesheet" type="text/css"> <script language="JavaScript" src="../fonctions.js"></script> <script language="JavaScript" src="fonctions.js"></script> <script language="JavaScript"> <!-- if (top.location.href == self.location.href) window.location.href = 'frames.php'; //--> </script> <h3 align=center><? echo $lang[0]; ?></h3> <p align=center class=10><a href="news_form.php?act=0" OnClick="news_form=open_news_form('');" target="news_form"><? echo $lang[11]; ?></a> - <a href="index_inscrits.php"><? echo $lang[18]; ?></a></p> <? if ($_GET['act']==2 && isset($_GET[nid])) { $sql="DELETE FROM $tables[news] WHERE new_id='$_GET[nid]'"; $result=mysql_query($sql); $sql="DELETE FROM $tables[news_photos] WHERE new_id='$_GET[nid]'"; $result=mysql_query($sql); } if (isset($_GET['s']) && $_GET['s']==0) { $sens="DESC"; $s=1; } else { $sens="ASC"; $s=0; } include("../includes/navigation_mois.inc.php"); ?> <table border="0" align="center" cellpadding="0" cellspacing="0" class=TABLEBORDER width="70%"> <tr> <td><? // bordure ?><table width="100%" border=0 cellspacing=1 cellpadding=3 align=center> <tr> <th width=100%><a href="?a=<? echo $_GET['a']; ?>&m=<? echo $m; ?>&o=0&s=<? echo $_GET['s']; ?>"><? echo $lang[13]; ?></a></th> <th><a href="?a=<? echo $_GET['a']; ?>&m=<? echo $m; ?>&o=1&s=<? echo $_GET['s']; ?>"><? echo $lang[16]; ?></a></th> <th><a href="?a=<? echo $_GET['a']; ?>&m=<? echo $m; ?>&o=2&s=<? echo $_GET['s']; ?>"><? echo $lang[14]; ?></a></th> <th width=15><img src="../images/editer.gif" alt="<? echo $bt_lang[1] ?>"></th> <th width=15><img src="../images/supprimer.gif" alt="<? echo $bt_lang[2] ?>"></th></tr> </tr> <? $order[]="titre"; $order[]="nick"; $order[]="date"; if ($order[$_GET['o']]=="") $o=2; else $o=$_GET['o']; $sql="SELECT t1.*, nick FROM $tables[news] as t1, $tables[users] as t2 WHERE t1.user_id=t2.user_id AND year(date)=".$a." AND month(date)=".$m." ORDER BY " . $order[$o] . " $sens"; $result=mysql_query($sql); for ($i=0;$result && $row=mysql_fetch_array($result);$i++) { $date=mysql2date($row['date']); /* if ($row[texte]!="") $texte="<img src=\"". WWWROOT . "/" . IMAGESDIR ."/notes.gif\" alt=\"".addslashes(remove_tags($row[texte]))."\" align=absmiddle>"; else $texte=""; */ if ($i & 1) $style=1; else $style=2; echo "<tr class=TABLEDATA$style onmouseover=\"this.className='TABLEDATAO'\" onmouseout=\"this.className='TABLEDATA$style'\"> <td nowrap>".remove_tags($row['titre'])." $texte</td> <td>$row[nick]</td> <td align=center nowrap>$date - $row[heure]</td> <td align=center> <a href=\"news_form.php?act=1&nid=$row[new_id]\" OnClick=\"news_form=open_news_form('');\" target=\"news_form\"> <img src=\"../images/editer.gif\" border=0 alt=\"$bt_lang[1]\"> </a> </td> <td align=center>"; echo "<a href=\"?act=2&nid=$row[new_id]\" OnClick=\"if (confirm('$msg_lang[3]')) return true; else return false;\">"; echo "<img src=\"../images/supprimer.gif\" border=0 alt=\"$bt_lang[2]\">"; echo "</a>"; echo "</td></tr>\n"; } ?> </table><? // bordure ?></td> </tr> </table> <p align=center class=10><a href="news_form.php?act=0" OnClick="news_form=open_news_form('');" target="news_form"><? echo $lang[11]; ?></a> - <a href="index_inscrits.php"><? echo $lang[18]; ?></a></p> </form> </body> </html>
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 <? include("../includes/mois.inc.php"); if (!isset($_GET['a']) || (int)$_GET['a']==0) $a=date("Y"); else $a=$_GET['a']; if (!isset($_GET['m']) || (int)$_GET['m']==0) $m=date("m"); else $m=$_GET['m']; echo "<table border=0 cellpadding=2 cellspacing=2 align=center>"; $indexm=(int)$m; $ap=$a-1; $as=$a+1; echo "<tr> <td><a href=\"index.php?a=$ap&m=$m&o=".$_GET['o']."&s=".$_GET['s']."\"><img src=\"". WWWROOT."/".IMAGESDIR."/gg.gif\" border=0></a></td>\n <td colspan=12 align=center class=12><strong>$mois[$indexm] $a</strong></td>\n <td><a href=\"index.php?a=$as&m=$m&o=".$_GET['o']."&s=".$_GET['s']."\"><img src=\"". WWWROOT."/".IMAGESDIR."/dd.gif\" border=0></a></td>\n </tr>"; echo "<tr>"; if ($indexm==1) { $mprec=12; $aprec=$a-1; } else { $mprec=$indexm-1; $aprec=$a; } if ($indexm==12) { $msuiv=1; $asuiv=$a+1; } else { $msuiv=$indexm+1; $asuiv=$a; } $mprec=sprintf("%02d",$mprec); $msuiv=sprintf("%02d",$msuiv); echo "<td><a href=\"index.php?a=$aprec&m=$mprec&o=".$_GET['o']."&s=".$_GET['s']."\"><img src=\"". WWWROOT."/".IMAGESDIR."/g.gif\" border=0></a></td>"; for ($i=1;$i<=12;$i++) { $mo=sprintf("%02d",$i); if ($indexm!=$i) echo "<td><a href=\"index.php?a=$a&m=$mo&o=".$_GET['o']."&s=".$_GET['s']."\">".$mois_s[$i]."</a></td>"; else echo "<td>".$mois_s[$i]."</td>"; } echo "<td><a href=\"index.php?a=$asuiv&m=$msuiv&o=".$_GET['o']."&s=".$_GET['s']."\"><img src=\"". WWWROOT."/".IMAGESDIR."/d.gif\" border=0></a></td>"; echo "</tr>"; echo "</table>"; ?>
Partager