Erreurs de compilation :Undefined offset

cs_faty86 Messages postés 20 Date d'inscription mercredi 20 février 2008 Statut Membre Dernière intervention 5 juin 2008 - 20 avril 2008 à 17:34
cs_faty86 Messages postés 20 Date d'inscription mercredi 20 février 2008 Statut Membre Dernière intervention 5 juin 2008 - 20 avril 2008 à 18:55
Salut !!
J'ai un code php et lors de la compilation j'ai 2erreurs que je n'arrive pas a trouver !
Voici le resultat de la compilation :

"partie supprimer site
Notice: Undefined offset: 2 in c:\program files\easyphp1-8\www\rymouchacode\affsite.php on line 129

Notice: Undefined offset: 2 in c:\program files\easyphp1-8\www\rymouchacode\affsite.php on line 134"

Voici mon code :

<?php
               $link = mysql_connect("localhost","root","");
  mysql_select_db('administration equip');


  $res=mysql_query("select * from Site where ID_Site='".$_POST["liste"]."'");
                $res2=mysql_query("select * from Connexion where ID_Site_CNX='".$_POST["liste"]."'");
               
                if(mysql_num_rows($res)==0)
         { 
   header("location:erreur.php");
         }
  else
        {
   $lig=mysql_fetch_array($res);


                                              echo'<html>';
                    echo'<head>';
                    echo'</head>';
                       echo'';
                                              
                                                 if(isset($_POST['bouton']))
                                                  {
                                                    switch ($_POST['bouton'])
                                                     
                                                         {
                                                        case 'Supprimer Site':
                                                        {


                                                         echo'partie supprimer site';
                                                           $tabcnx=array();
                                                           $tabeq=array();
                                                           $i=0;
                                                           $k=0;
                                                           if(mysql_num_rows($res2)==0)
                                                               {
                                                              
                                                                  $req=mysql_query("delete from Site where ID_Site='".$_POST["liste"]."'");
                                                                  echo'suppression site reussie';
                                                               } 
                                                            else
                                                               { while($ln=mysql_fetch_array($res2))
                                                                    {$tabcnx[$i]='.$ln[ID_CNX].';
                                                                     $i++;
                                                                    }
                                                                for($j=1;$j<=$i;$j++)
                                                                    {
                                           ==>ligne129         $res3=mysql_query("select * from Etat where ID_CNX_E='$tabcnx[$j]'"); 
                                                                      
                                                                       if(mysql_num_rows($res3)==0)
                                                                       
                                                                          {
                                            ==>ligne134            $req=mysql_query("delete from Connexion where ID_CNX='$tabcnx[$j]'");
                      
                                                                          }
                                                                    
                                                                       else
                                                                          { while($ln1=mysql_fetch_array($res3))
                                                                          
                                                                               {$tabeq[$k]='.$ln1[ID_EQ_E].';
                                                                                $k++; 
                                                                               } 
                                                                            for($f=1;$f<=$k;$f++)
                                                                               { 
                               $req=mysql_query("delete from `Etat` where `ID_CNX_E`='$tabcnx[$j]' and `ID_EQ_E`='$tabeq[$f]'");
                                                                       }
                                                                        $req2=("delete from Connexion where ID_CNX='$tabcnx[$j]'");
                                                                        
                                                                          }
                                                                     }
                                                             


                                                                     $req4=mysql_query("delete from `Site` where `ID_Site`='".$_POST["liste"]."'");
                                                                  }
                                                         
                                                             break;}
                                                        }
                               
                                          }
                         }


mysql_close($link);
?>
</form>

</html>
Vraiment je n'arrive pas a trouver ce qui cloche!!! merci de m'aider

3 réponses

malalam Messages postés 10839 Date d'inscription lundi 24 février 2003 Statut Membre Dernière intervention 2 mars 2010 25
20 avril 2008 à 18:45
Hello,

le problème est exactement ce que te dit php : Un tableau contient un index valant 2 qui n'existe pas.
$tabcnx[$j] => $j vaut 2, et $tabcnx[2) n'existe pas.
0
cs_faty86 Messages postés 20 Date d'inscription mercredi 20 février 2008 Statut Membre Dernière intervention 5 juin 2008
20 avril 2008 à 18:54
J'ai pas compris, comment je peux la corriger??
0
cs_faty86 Messages postés 20 Date d'inscription mercredi 20 février 2008 Statut Membre Dernière intervention 5 juin 2008
20 avril 2008 à 18:55
Comment il n'existe pas puisque j'ai rempli le tableau tabcnx avant de faire la requete!!
0
Rejoignez-nous