Bonjour,
J'ai un petit pepin avec la fonction mysql_fetch_array(). (je suis sous wamp)
voici le message d'erreur:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\infoRotter\menutop.php on line 10
les fichiers:
index.php:
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
 
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/Strict.dtd">
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="styles.css">
<title>Info Rottersac</title>
</head>
<body>
<?php
 $n1 = @isset($_GET['n1']) ? $_GET['n1'] : NULL;
  $n2 = @isset($_GET['n2']) ? $_GET['n2'] : NULL;
 $n3 = @isset($_GET['n3']) ? $_GET['n3'] : NULL; 
 $n4 = @isset($_GET['n4']) ? $_GET['n4'] : NULL;
$n5 = @isset($_GET['n5']) ? $_GET['n5'] : NULL;
$prog = @isset($_GET['prog']) ? $_GET['prog'] : NULL;
 
function mysql_DateTime($d)
  {
  $date = substr($d,8,2)."/";
  $date = $date.substr($d,5,2)."/";
  $date = $date.substr($d,0,4). " ";
  $date = $date.substr($d,11,5);
  return $date;
  }
include ('connection.php');
$sql='INSERT INTO visites ( `id` , `ip` , `visite` ) VALUES (NULL , "'.$_SERVER["REMOTE_ADDR"].'", NULL)';
mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
 
if (isset($n5))
  {
  $sql='INSERT INTO visitescat ( `id` , `ip` , `ncat` , `cat` , `visite` ) VALUES (NULL , "'.$_SERVER["REMOTE_ADDR"].'",5,'.$n5.',NULL)';
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  }
elseif (isset($n3))
  {
  $sql='INSERT INTO visitescat ( `id` , `ip` , `ncat` , `cat` , `visite` ) VALUES (NULL , "'.$_SERVER["REMOTE_ADDR"].'",3,'.$n3.',NULL)';
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  }
if (isset($_POST['nom']))
  {
  if ($_POST['nom']!="Deconnexion")
    {
    $sql="select * from users where nom like '".$_POST['nom']."' and password like '".$_POST['password']."' LIMIT 1";
    mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
    if (@mysql_num_rows($resultat)==0)
      {
          $motdepasse="KO";
      }
    else
      {
        $rang=mysql_fetch_array($resultat);
        $motdepasse="OK";
        $iduser=$rang['id'];
        $nomuser=$rang['prenomuser'];
        $habged=$rang['habged'];
        $habfds=$rang['habfds'];
        $habmail=$rang['habmail'];
        $habadm=$rang['habadm'];
    $_SESSION["motdepasse"]=$motdepasse;
    $_SESSION["habfds"]=$habfds;
    $_SESSION["habged"]=$habged;
    $_SESSION["habmail"]=$habmail;
    $_SESSION["habadm"]=$habadm;
    $_SESSION["iduser"]=$iduser;
   $_SESSION["nomuser"]=$nomuser;
      }
    }
  else
    {
    $motdepasse="";
    $habfds="";
    $habged="";
    $habmail="";
    $habadm="";
    $iduser="";
    $nomuser="";
    $_SESSION["motdepasse"]=$motdepasse;
    $_SESSION["habfds"]=$habfds;
    $_SESSION["habged"]=$habged;
    $_SESSION["habmail"]=$habmail;
    $_SESSION["habadm"]=$habadm;
    $_SESSION["iduser"]=$iduser;
   $_SESSION["nomuser"]=$nomuser;
    }
  }
  else{
   $motdepasse = @isset($_SESSION['motdepasse']) ? $_SESSION['motdepasse'] : NULL;
   $habfds = @isset($_GET['habfds']) ? $_GET['habfds'] : NULL;
   $habged = @isset($_GET['habged']) ? $_GET['habged'] : NULL;
   $habmail = @isset($_GET['habmail']) ? $_GET['habmail'] : NULL; 
   $habadm = @isset($_GET['habadm']) ? $_GET['habadm'] : NULL; 
    $iduser = @isset($_GET['iduser']) ? $_GET['iduser'] : NULL;
   $nomuser = @isset($_GET['nomuser']) ? $_GET['nomuser'] : NULL;
 
  //Traitement des variable de session
  }
?>
<a href="index.php"><img src="logo.gif" alt="Ahlstrom - Info Rottersac" title="Ahlstrom - Info Rottersac" ></a>
<?php include('menutop.php'); ?>
<div id="bandeau">Bienvenue</div>
<div id="menu"><div id="menu_haut">
<?php
if (isset($n2))
  {
  $sql="select id, nom from catn3 where mere=".$n2." order by nom;";
  $resultat=@mysql_db_query($dbname,$sql,$id_link);
  while ($rang=mysql_fetch_array($resultat))
    {
    $id=$rang['id'];
    $nom=$rang['nom'];
    echo '<a href="index.php?n1='.$n1.'&amp;n2='.$n2.'&amp;n3='.$id.'" class="lien3">'.$nom.'</a>';
    }
  }
?>
</div><div id="menu_bas"><BR>
<?php
$sql="select id, nom from catn5 where mere=0 order by nom";
mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
 
while ($rang=mysql_fetch_array($resultat))
  {
  $id=$rang['id'];
  $nom=$rang['nom'];
  echo '<a href="index.php?n5='.$id.'" class="lien">'.$nom.'</a><BR>';
  }
?>
<BR>
<a href="index.php?prog=rechercher.php" class="lien">Rechercher</a><BR>
<a href="index.php?prog=telecharges.php" class="lien">Les plus téléchargés</a><BR>
<a href="index.php?prog=recents.php" class="lien">Les plus récents</a><BR>
<a href="index.php?prog=fds/listefds.php&amp;order=nom&amp;tri=desc" class="lien">Liste Produits</a><BR>
<a href="index.php?prog=trombi.php&amp;order=nom&amp;tri=desc" class="lien">Trombinoscope</a><BR>
 
<?php
if ($habadm=="OK")
  {
  echo '<a href="documents/guide/Guide%20administrateur.doc" target="_blank" class="lien">Guide administrateur</a><BR>';
  }
else
  {
  echo '<a href="documents/guide/Guide%20utilisateur.doc" target="_blank" class="lien">Guide utilisateur</a><BR>';
  }
if ($habmail=="OK")
  {
  $sql="select sujet from mails where dest=".$iduser." and datelecture = '0000-00-00 00:00:00' and datesupp = '0000-00-00 00:00:00'";
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  $memos=@mysql_num_rows($resultat);
  if ($memos>1) {echo '<BR><a href="index.php?prog=mail/maboite.php" class="lien"><font color=#FF0000>'.$memos.' mémos non lus</font></a>';}
  if ($memos==1) {echo '<BR><a href="index.php?prog=mail/maboite.php" class="lien"><font color=#FF0000>1 mémo non lu</font></a>';}
  if ($memos==0) {echo '<BR><a href="index.php?prog=mail/maboite.php" class="lien">Ma boite</a>';}
  echo '<BR><a href="index.php?prog=mail/mail.php" class="lien">Envoyer un memo</a>';
  echo '<BR><a href="index.php?prog=mail/envoyes.php" class="lien">Mémos envoyés</a><BR>';
  } 
if ($motdepasse=="OK") {echo '<BR><a href="index.php?prog=changepwd.php" class="lien">Changer de mot de passe</a>';}
if ($habfds=="OK") { echo '<BR><a href="index.php?prog=fds/saisiefds2.php" class="lien">Saisie nouveaux produits</a>';}
if ($habged=="OK") { echo '<BR><a href="index.php?prog=doc/soumettredoc.php" class="lien">Soumettre un doc</a>';}
?>
</div><div id="menu_pied">
<?php
if ($motdepasse!="OK")
  {
  echo '
  <form id="user" action="index.php" method="post">
        Nom :<BR>
        <input type="text" name="nom" size="15" maxlength="40"><BR>
        Mot de passe :<BR>
        <input type="password" name="password" size="15" maxlength="40">';
  if ($motdepasse=="KO")
    {
    echo '<font color="#FF0000">Login incorrect !</font><BR>';
    $motdepasse="";
    session_register("motdepasse");
    }
  echo '<input type="submit" value="Connecter"></form>';
  }
else
  {
  echo '<form id="user" action="index.php" method="post">Bonjour '.$nomuser.'...<BR><BR><input type="hidden" name="nom" value="Deconnexion">';
  echo '<input type="submit" value="Se deconnecter"></form>';
  }
?>
<a href="admin" class="lien">Administrateur</a><BR>
</div></div>
 
<div id="contenu">
<div  style="vertical-align:bottom; bottom:0px;position:relative;margin:auto;text-align:center;width:100%">
    <center>En cas de problème, n'hésitez pas à contacter l'administrateur du site
              <a href="mailto:vincent.bach@ahlstrom.com?subject=Demande Aide site infoRotter&amp;cc=thierry.desplat@ahlstrom.com">ici</a>
</center>
</div>
<?php
if (isset($n5))
  {
    if (isset($n4))
        {
        $sql="select nom from catn4 where id=".$n4." order by nom";
      mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
        $rang=mysql_fetch_array($resultat);
        $titre=$rang['nom']." / ";
    }
    $sql="select nom from catn5 where id=".$n5." order by nom";
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
    $rang=mysql_fetch_array($resultat);
    echo '<table><tr><td></td><td style="padding-left:20px"><div id="titre">'.$titre.$rang['nom'].'</div>';
    $sql="select idfile from liens where ncat='5' and cat=".$n5;
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  $i=0;
  while ($rang=mysql_fetch_array($resultat))
    {
    $id=$rang['idfile'];
    $sql2="select nom, id, description, document from fichiers where id=".$id." LIMIT 1";
        mysql_select_db($dbname);
$resultat2=mysql_query($sql2,$id_link);
 
        $rang2=mysql_fetch_array($resultat2);
    $tableau[$i]['nom']=$rang2['nom'];
    $tableau[$i]['id']=$rang2['id'];
    $tableau[$i]['description']=$rang2['description'];
    $tableau[$i]['document']=$rang2['document'];
    $i++;
    }
  if (!empty($tableau))
    {
    sort($tableau);
    for ($i=0;$i<count($tableau);$i++)
      {
      echo '<a href="ouvredoc.php?id='.$tableau[$i]['id'].'" target="_blank" class="lien">'.$tableau[$i]['nom'];
      if (!empty($tableau[$i]['description'])) {echo ' (<i>'.$tableau[$i]['description'].'</i>)';}
      echo '</a><BR>';
      }
    }
  $tableau=array();
  echo '</td></tr></table>';
  }
elseif (isset($n3))
  {
  $sql="select description, image from catn3 where id=".$n3.";";
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  $rang=mysql_fetch_array($resultat);
  $description=$rang['description'];
  $image=$rang['image'];
  $sql2="select id, nom from catn4 where mere=".$n3." order by nom";
  mysql_select_db($dbname);
$resultat2=mysql_query($sql2,$id_link);
 
  echo '<table width="100%">
               <tr>
                   <td valign="top" >';
  if (trim($description))
     {
             echo '<div style="font-size:15px;">'.nl2br($description).'</div>';
     }
  if (trim($image)) {echo '<img src="documents/images/'.$image.'">';}
  echo '            </td>
                    <td valign="top" width="100%" style="padding-left:20px">';
  while ($rang2=mysql_fetch_array($resultat2))
    {
    $id2=$rang2['id'];
    $nom2=$rang2['nom'];
    echo '<div id="titre">'.$nom2.'</div>';
        $sql3="select idfile from liens where ncat='4' and cat=".$id2;
		mysql_select_db($dbname);
$resultat3=mysql_query($sql3,$id_link);
 
    $i=0;
    while ($rang3=mysql_fetch_array($resultat3))
      {
      $id3=$rang3['idfile'];
      $sql4="select nom, id, description, document from fichiers where id=".$id3." LIMIT 1";
 
		  mysql_select_db($dbname);
$resultat4=mysql_query($sql4,$id_link);
          $rang4=mysql_fetch_array($resultat4);
      $tableau[$i]['nom']=$rang4['nom'];
      $tableau[$i]['id']=$rang4['id'];
      $tableau[$i]['description']=$rang4['description'];
      $tableau[$i]['document']=$rang4['document'];
      $i++;
      }
    if (!empty($tableau))
      {
      sort($tableau);
      for ($i=0;$i<count($tableau);$i++)
      {
        echo '<a href="ouvredoc.php?id='.$tableau[$i]['id'].'" target="_blank" class="lien">'.$tableau[$i]['nom'];
        if (!empty($tableau[$i]['description'])) {echo ' (<i>'.$tableau[$i]['description'].'</i>)';}
        echo '</a><BR>';
      }
    }
    $tableau=array();
    $sql5="select id, nom from catn5 where mere=".$id2." order by nom";
	mysql_select_db($dbname);
$resultat5=mysql_query($sql5,$id_link);
 
    while ($rang5=mysql_fetch_array($resultat5))
      {
      $id5=$rang5['id'];
      $nom5=$rang5['nom'];
      echo '<a href="index.php?n1='.$n1.'&n2='.$n2.'&n3='.$n3.'&n4='.$id2.'&n5='.$id5.'" class="lien4">> '.$nom5.'</a>';
      }
        }
  echo '</td></tr></table>';
  }
elseif (isset($n2))
  {
  $sql="select description, image from catn2 where id=".$n2.";";
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  $rang=mysql_fetch_array($resultat);
  $description=$rang['description'];
  $image=$rang['image'];
  echo '<table align="center" width="80%" style="height:80%">
               <tr  align="center">
                    <td><div style="font-size:15px;">'.nl2br($description).'</div></td>
               </tr>' ;
  if (trim($image))
     {
         echo '<tr align="center"><td><img src="documents/images/'.$image.'"></td></tr>';
     }
  echo '</table>';
  }
elseif (isset($prog)) {include ($prog); }
else
  {
  $sql="select * from news order by date desc LIMIT 10";
  mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
  echo '<table width="100%" style="height:100%">
               <tr>
                   <td>';
  while ($rang=mysql_fetch_array($resultat))
    {
    echo '<table cellspacing=0 cellpadding=5 align="center" width="80%">
                 <tr>
                     <td colspan=2>
                         <div id="titre">'.$rang['titre'].'</div>
                     </td>
                 </tr>
                     <tr> <td width="100%" valign="top" colspan=2><i><b>'.mysql_DateTime($rang['date']).'</b></i><br/>'.nl2br($rang['texte']).'</td>  </tr>
                 <tr>
                     <td valign="top" colspan=2>';
    if (trim($rang['illustration'])) echo '<a href="documents/images/'.$rang['illustration'].'" target="_blank" alt="Ouvrir l image en plein écran" title="Ouvrir l image en plein écran"><img src="documents/images/'.$rang['illustration'].'" alt="Ouvrir l image en plein écran" title="Ouvrir l image en plein écran" width="700"></a>';
 
    echo '
                     </td >
                 </tr>
           </table>';
    }
  echo '</td></tr></table>';
  }
?>
</div>
 
 
</body>
</html>
menutop.php:

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
 
<?php
require_once 'conf.php';
require_once 'menu.php';
include ('connection.php');
$menu=new Menu;
$sql="select id, nom from catn1 order by nom";
mysql_select_db($dbname);
$resultat=mysql_query($sql,$id_link);
//$menu->addMenu($nom, $adresse="#", $parentMenu="root", $image=NULL, $target='_self', $titre=NULL)
while ($rang= mysql_fetch_array($resultat) )
   {
   $id=$rang['id'];
   $nom=$rang['nom'];
 
   $menu->addMenu($nom.$id,'','root','','',$nom);
   $sql2="select id, nom from catn2 where mere=".$id." order by nom";
 
   mysql_select_db($dbname);
   $resultat2=mysql_query($sql2,$id_link);
 
   while ($rang2=mysql_fetch_array($resultat2))
      {
      $id2=$rang2['id'];
      $nom2=$rang2['nom'];
      $menu->addMenu($nom2.$id2,'index.php?n1='.$id.'&n2='.$id2,$nom.$id,'','',$nom2);
      }  
   }
?>
si dans menutop.php je rajoute
ca me met: "No database selected "
Je suppose donc qu'il s'agit d'un probleme d'acces à la Base De Données sélectionnée...
mais je ne sais pas trop quoi modifier pour arranger ca...

Merci d'avance

PS: expliquez simplement s'il vous plait, je débute...