IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Erreur de programmation PHP & MySQL (Notice: Undefined offset: 890) [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut Erreur de programmation PHP & MySQL (Notice: Undefined offset: 890)
    Bonjour,

    En ce moment, j'ai un projet de programmation où je dois reprendre le code d'un ancien collègue pour corriger ses erreurs. Malheureusement, ce n'est pas de tout repos !!

    Le code ci-dessous doit généré un tableau, mais lorsque j'affiche ma page, l'erreur suivante apparait au dessus de mon tableau :

    "Notice: Undefined offset: 890 in C:\wamp\www\absence\gestweekend.php on line 27
    Call Stack
    "

    Je suis encore loin d'être un expert, et je voulais d'abord savoir si c'est une erreur PHP ou MySQL (je pense que c'est une erreur MySQL !).

    Code de la page :
    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
    <?php
    session_start();
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    
    	<head>
    		<title>INTRANET Le Chevalon: Gestion du weekend</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<link rel="stylesheet" media="screen" type="text/css" title="Design" href="../design.css" />
    		<script type="text/javascript" src="menu.js"></script>
    	
    	</head>
    	
    	<body>
    		<?php
    			include("../connect_bdd.php"); 
    			if(isset($_POST['data'])) {
    			
    				$Datearrmid=implode("-", $_POST['AbsMidi']);
    				$Jourtransmid[]=explode("-", $Datearrmid);
    				$Datearrsoi=implode("-", $_POST['AbsSoir']);
    				$Jourtranssoi[]=explode("-", $Datearrsoi);
    				$Datearrnui=implode("-", $_POST['AbsNuit']);
    				$Jourtransnui[]=explode("-", $Datearrnui);
    		
    				for($boucletableau=0; $Jourtransmid[0][5*$boucletableau] !== NULL ; $boucletableau++){
    					set_time_limit(25);
    					$jourmid = $Jourtransmid[0][5*$boucletableau+2] . "-" . $Jourtransmid[0][5*$boucletableau+3] . "-" . $Jourtransmid[0][5*$boucletableau+4];
    					$jourmidel = $Jourtransmid[0][5*$boucletableau+1];
    					$jourmidval = $Jourtransmid[0][5*$boucletableau];
    					$joursoi = $Jourtranssoi[0][5*$boucletableau+2] . "-" . $Jourtranssoi[0][5*$boucletableau+3] . "-" . $Jourtranssoi[0][5*$boucletableau+4];
    					$joursoiel = $Jourtranssoi[0][5*$boucletableau+1];
    					$joursoival = $Jourtranssoi[0][5*$boucletableau];
    					$journui = $Jourtransnui[0][5*$boucletableau+2] . "-" . $Jourtransnui[0][5*$boucletableau+3] . "-" . $Jourtransnui[0][5*$boucletableau+4];
    					$journuiel = $Jourtransnui[0][5*$boucletableau+1];
    					$journuival = $Jourtransnui[0][5*$boucletableau];
    
    					//Insertion (vérification, création absence)
    					$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $jourmidel . ' AND a.idDate ="' . $jourmid . '"');
    					$updt = $chupdt->fetch();
    					if ($updt[0] !== NULL) {
    						$req = $bdd->prepare('UPDATE absence SET AbsMidi = :AbsMidi WHERE idEleve = :idEleve AND idDate = :idDate');
    						$req->execute(array('AbsMidi' => $jourmidval, 'idEleve' => $jourmidel, 'idDate' => $jourmid));
    					}
    					else {
    						$req = $bdd->prepare('INSERT INTO absence(AbsMidi, idEleve, idDate) VALUES(:AbsMidi, :idEleve, :idDate)');
    						$req->execute(array('AbsMidi' => $jourmidval, 'idEleve' => $jourmidel, 'idDate' => $jourmid ));
    					}
    					$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $joursoiel . ' AND a.idDate ="' . $joursoi . '"');
    					$updt = $chupdt->fetch();
    					if ($updt[0] !== NULL) {
    						$req = $bdd->prepare('UPDATE absence SET AbsSoir = :AbsSoir WHERE idEleve = :idEleve AND idDate = :idDate');
    						$req->execute(array('AbsSoir' => $joursoival, 'idEleve' => $joursoiel, 'idDate' => $joursoi));
    					}
    					else {
    						$req = $bdd->prepare('INSERT INTO absence(AbsSoir, idEleve, idDate) VALUES(:AbsSoir, :idEleve, :idDate)');
    						$req->execute(array('AbsSoir' => $joursoival, 'idEleve' => $joursoiel, 'idDate' => $joursoi ));
    					}
    					$chupdt = $bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $journuiel . ' AND a.idDate ="' . $journui . '"');
    					$updt = $chupdt->fetch();
    					if ($updt[0] !== NULL) {
    						$req = $bdd->prepare('UPDATE absence SET AbsNuit = :AbsNuit WHERE idEleve = :idEleve AND idDate = :idDate');
    						$req->execute(array('AbsNuit' => $journuival, 'idEleve' => $journuiel, 'idDate' => $journui));
    					}
    					else {
    						$req = $bdd->prepare('INSERT INTO absence(AbsNuit, idEleve, idDate) VALUES(:AbsNuit, :idEleve, :idDate)');
    						$req->execute(array('AbsNuit' => $journuival, 'idEleve' => $journuiel, 'idDate' => $journui ));
    					}
    				}
    				$req = $bdd->prepare('UPDATE weekendvac SET Ferme = :Ferme WHERE idWevac = :weekendvac');
    				$req->execute(array('Ferme' => $_POST['Wkdtype'], 'weekendvac' => $_POST['idWevac'] ));
    			} 
    			if(isset($_POST['idWevac'])) {
    				echo '<form method="post" action="./gestweekend.php">';
    				
    					$choixwkdt=$bdd->query('SELECT * FROM weekendvac WHERE idWevac = ' . $_POST['idWevac']) ;
    					$wkdt = $choixwkdt->fetch();
    					
    					echo ' <select name="Wkdtype" id="Wkdtype">
    					<option value="0" '; if($wkdt['Ferme'] == '0' ) { echo 'selected="selected"'; } echo ' > Weekend ouvert</option>
    					<option value="1" '; if($wkdt['Ferme'] == '1' ) { echo'selected="selected"'; } echo ' > Weekend fermé </option>
    					</select>';
    					
    					$choixdeb=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee  FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC LIMIT 0, 1') ;
    					$wedeb = $choixdeb->fetch();
    					$choixfin=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate DESC LIMIT 0, 1') ;
    					$wefin = $choixfin->fetch();
    					$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
    					$num_jourdeb = date("w", mktime(0, 0, 0, $wedeb['mois'], $wedeb['jour'], $wedeb['annee']));
    					$nom_jourdeb = $tab_jour[$num_jourdeb];
    					$num_jourfin = date("w", mktime(0, 0, 0, $wefin['mois'], $wefin['jour'], $wefin['annee']));
    					$nom_jourfin = $tab_jour[$num_jourfin];
    					
    					echo '<table>
    						<caption> Gestion des absences du weekend du '. $nom_jourdeb . ' ' . $wedeb['jour'] . '/' . $wedeb['mois'] . '/' . $wedeb['annee'] . ' au '. $nom_jourfin . ' ' . $wefin['jour'] . '/' . $wefin['mois'] . '/' . $wefin['annee'] . '</caption>'; 
    						
    						$tabjour=$bdd->query('SELECT *,  DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC') ;
    						
    						echo '<thead>
    							<tr>
    								<th> Elève </th>';
    								while ($jourf = $tabjour->fetch()) {
    								
    									$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
    									$num_jourf = date("w", mktime(0, 0, 0, $jourf['mois'], $jourf['jour'], $jourf['annee']));
    									$nom_jourf = $tab_jour[$num_jourf];
    									
    									echo '<th>' . $nom_jourf . ' ' . $jourf['jour'] . '/' . $jourf['mois'] . '/' . $jourf['annee'] . '</th>';
    								}
    								echo '<input type="hidden" name="data" value="data" />
    								<input type="hidden" name="idWevac" value="' . $_POST['idWevac'] . '" />
    							</tr>
    						</thead>';
    					
    						$choixel=$bdd->query('SELECT idEl, NomEl, PrenomEl, StatutChevEl FROM eleve e WHERE (e.StructEl = "Ent" OR e.StructEl = "Int" OR e.StructEl = "Sorta" )GROUP BY e.idEl ORDER BY e.NomEl '); 
    					
    						while ($el = $choixel->fetch()){
    							echo '<tr>
    								<td>' . $el['NomEl'] . ' ' . $el['PrenomEl'] . '</td>';
    							
    								$jourabs=$bdd->query('SELECT * FROM jour WHERE idWevac = ' . $_POST['idWevac'] . ' ORDER BY idDate ASC') ;
    								
    								while ($jrabs = $jourabs->fetch()) {
    									
    									$choixabs=$bdd->query('SELECT * FROM absence a WHERE a.idEleve =' . $el['idEl'] . ' AND a.idDate ="' . $jrabs['idDate'] . '"');
    									$abs = $choixabs->fetch();
    									
    									echo '<td> 
    										Absence midi: 
    										
    										<select name="AbsMidi['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id=AbsMidi['. $el['idEl']. $jrabs['idDate']. ']">
    											<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == '0' ) { echo ' selected="selected" '; } echo ' ></option>
    											<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'AbsHop') { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
    											<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'AbsPrevu' || $el['StatutChevEl'] == 'Appart'|| $el['StatutChevEl'] == 'Semi') { echo'selected="selected"'; } echo ' > Absence prévue </option>
    											<option value="RepasFroid-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasFroid') { echo'selected="selected"'; } echo ' > Repas froid </option>
    											<option value="RepasGarde-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasGarde') { echo'selected="selected"'; } echo ' > Repas gardé </option>
    											<option value="RepasExt-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasExt') { echo'selected="selected"'; } echo ' > Repas extérieur </option>
    											<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'Abs') { echo'selected="selected"'; } echo ' > Absence injustifié </option>
    										</select><br />
    										
    										Absence soir:
    										
    										<select name="AbsSoir['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id="AbsSoir['. $el['idEl']. $jrabs['idDate']. ']">
    											<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == '0' ) { echo 'selected="selected"'; } echo ' > </option>
    											<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'AbsHop') { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
    											<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'AbsPrevu' || $el['StatutChevEl'] == 'Appart'|| $el['StatutChevEl'] == 'Semi') { echo'selected="selected"'; } echo ' >  Absence prévue </option>
    											<option value="RepasFroid-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'RepasFroid') { echo'selected="selected"'; } echo ' > Repas froid </option>
    											<option value="RepasGarde-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'RepasGarde') { echo'selected="selected"'; } echo ' > Repas gardé </option>
    											<option value="RepasExt-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsMidi'] == 'RepasExt') { echo'selected="selected"'; } echo ' > Repas extérieur </option>
    											<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsSoir'] == 'Abs') { echo'selected="selected"'; } echo ' > Absence injustifié </option>
    										</select><br />
    										
    										Absence nuit:
    										
    										<select name="AbsNuit['. $el['idEl'] .'-' . $jrabs['idDate']. ']" id="AbsNuit'. $el['idEl'] .'/'.$jrabs['idDate'] . '">
    											<option value="0-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == '0' ) { echo 'selected="selected"'; } echo ' ></option>
    											<option value="AbsHop-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "AbsHop") { echo'selected="selected"'; } echo ' > Absence hospitalière </option>
    											<option value="AbsPrevu-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "AbsPrevu") { echo'selected="selected"'; } echo ' > Absence prévue </option>
    											<option value="Abs-'. $el['idEl'] .'-' . $jrabs['idDate']. '" '; if($abs['AbsNuit'] == "Abs") { echo'selected="selected"'; } echo ' >  Absence injustifié </option>
    										</select>
    									</td>';
    								}
    							echo'</tr>' ;
    						}
    					echo '</table>';
    		?>
    					<input type="submit" value="Valider" />
    				
    					<!-- BOUTON DE RETOUR HAUT DE PAGE -->
    					<a href="#"><input type="button" name="Haut de page" id="Haut de page" value="Haut de page" /></a>
    			
    				</form>
    		<?php 
    			}
    			else {
    		?>
    				<p> <!-- Page de choix de départ -->
    					<form method="post" action="./gestweekend.php">
    						<label for="Choix We">Choix du weekend : </label><br />
    						<select name="idWevac" id="idWevac">
    		<?php
    							$choixwe=$bdd->query('SELECT * FROM weekendvac v INNER JOIN jour j ON v.idWevac = j.idWevac GROUP BY v.idWevac ORDER BY j.idDate DESC') ; 
    							
    							while ($we = $choixwe->fetch()){		//Boucle d'affichage des recherche
    								
    								$choixdeb=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee  FROM jour WHERE idWevac = ' . $we['idWevac'] . ' ORDER BY idDate ASC LIMIT 0, 1') ;
    								
    								while ($wedeb = $choixdeb->fetch()){
    								
    									$choixfin=$bdd->query('SELECT DAY(idDate) AS jour, MONTH(idDate) AS mois, YEAR(idDate) AS annee FROM jour WHERE idWevac = ' . $we['idWevac'] . ' ORDER BY idDate DESC LIMIT 0, 1') ;
    									
    									while ($wefin = $choixfin->fetch()){
    										
    										$tab_jour = array(0 =>'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
    										$num_jourdeb = date("w", mktime(0, 0, 0, $wedeb['mois'], $wedeb['jour'], $wedeb['annee']));
    										$nom_jourdeb = $tab_jour[$num_jourdeb];
    										$num_jourfin = date("w", mktime(0, 0, 0, $wefin['mois'], $wefin['jour'], $wefin['annee']));
    										$nom_jourfin = $tab_jour[$num_jourfin];
    										echo '<option value="' . $we['idWevac'] . '">Weekend du '. $nom_jourdeb . ' ' . $wedeb['jour'] . '/' . $wedeb['mois'] . '/' . $wedeb['annee'] . ' au '. $nom_jourfin . ' ' . $wefin['jour'] . '/' . $wefin['mois'] . '/' . $wefin['annee'] . '</option>';
    									
    									}
    								}
    							}
    		?> 
    						</select><br />
    						<input type="submit" value="Valider" />
    					</form>
    					
    					<a href="./gestcalendar.php" title="Gestion du calendrier">Si vous ne trouvez pas le weekend voulu, veuillez préalablement le créer. </a>
    				</p>
    		<?php // End
    			}
    		?>
    		</div>
    	</body>
    </html>
    La ligne en rouge est la ligne 27.
    D'après ce que j'ai pu voir c'est le fait d'utiliser un "for" dans ces conditions qui peut poser problème, est-ce vraiment ça ? Si oui, comment parrer à ce problème ?

    Merci pour votre aide.

    Cordialement

    Quentin

  2. #2
    Expert éminent sénior

    Avatar de FirePrawn
    Homme Profil pro
    Consultant technique
    Inscrit en
    Mars 2011
    Messages
    3 179
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Consultant technique

    Informations forums :
    Inscription : Mars 2011
    Messages : 3 179
    Points : 19 373
    Points
    19 373
    Par défaut
    Bonjour,

    C'est ton for qui est foireux
    Tu es censé utiliser la même variable partout...


  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut Merci
    Okay, merci beaucoup, maintenant je sais sur quoi me concentrer !

    "$var[0][5*$i]" est bien un tableau double ?

    for($boucletableau=0; $Jourtransmid[0][5*$boucletableau] !== NULL ; $boucletableau++){

    Comment refaire le for en testant un tableau double ?
    Dois-je de fixer la variable de la sorte $i = $Jourtransmid[0][0]; avant ma boucle ?

    Voici ce que je viens d'essayer mais sans succès :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    ...
    $boucletableau = 0;
     
    for($i=0; $Jourtransmid[0][$i] !== NULL; $i = $i+5){
    	...
    	$boucletableau++;
    }
    ...
    2ème essai sans succès :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    ...
    $boucletableau = 0;
    $i = 0;
     
    while($Jourtransmid[0][$i] !== NULL){
    	...
    	$boucletableau++;
    	$i = $i+5;
    }
    ...
    3ème essai sans succès : - résultat : la même erreur mais sur la ligne 93 (9 ici) cette fois !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    ...
    $boucletableau = 0;
    $testTab = $Jourtransmid[0][0];
     
    while($testTab !== NULL){
    	...
    	$boucletableau++;
    	$testTab = $Jourtransmid[0][5*$boucletableau];
    }
    ...
    quelqu'un ne verrait pas une solution ?

    Merci

  4. #4
    Membre du Club
    Femme Profil pro
    Consultant informatique
    Inscrit en
    Décembre 2011
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 42
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Décembre 2011
    Messages : 26
    Points : 51
    Points
    51
    Par défaut
    est-ce que tu peux nous dire ce qu'il y a dans ton tableau Jourtransmid avec un var_dump($Jourtransmid) par exemple avant la boucle.

  5. #5
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    Salut ; je crois que la ligne 27 fait référence a :
    $Jourtransnui[]=explode("-", $Datearrnui);
    donc essaye de revoir cette ligne en la désactivant pour vérifier

  6. #6
    Membre expert Avatar de RunCodePhp
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    2 962
    Détails du profil
    Informations personnelles :
    Localisation : Réunion

    Informations forums :
    Inscription : Janvier 2010
    Messages : 2 962
    Points : 3 947
    Points
    3 947
    Par défaut
    Salut

    A mon avis, quoi que tu fasse à ce niveau là, tu conserveras toujours un algo quelque peu pas très zen (pour ne pas dire tordu).

    L'origine du problème vient de l'étape d'avant, c'est à dire de la manière dont est construit le formulaire.
    Si tu veux obtenir quelque chose de plus propre, de plus logique qui au bout facilitera les traitements comme les UPDATE, INSERT (entre autre), c'est au niveau du formulaire qu'il faudrait agir.


    Ton prédécesseur ne savait pas apparemment qu'il est possible de structurer un formulaire de façon à renvoyer les données dans un (ou plusieurs) tableaux à plusieurs dimensions, ce qui justement facilite grandement les choses.

    Il a opté pour des astuces avec ces pléiades de tirets qui oblique à décortiquer les données.
    C'est ingérable vu la quantité de données concerné.

    Exemple basique :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    <input type="text" name="tab[element][0]" value="1" />
    <input type="text" name="tab[element][1]" value="2" />
    On obtiendra en POST un tableau à plusieurs dimensions :
    -> $_POST[tab]['element'][0] (valeur 1)
    -> $_POST[tab]['element'][1] (valeur 2)

    Une simple boucle avec foreach ($_POST[tab]['element'] as $element) (ou sur "tab)
    permet de récupérer tous les éléments.
    Difficile de faire plus simple.
    Mais dans ton cas il y a du boulot, malheureusement.


    De mon coté, il m'est impossible d'éplucher ton code, trop ... vaut mieux rien dire.

  7. #7
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut
    Citation Envoyé par redoran Voir le message
    Salut ; je crois que la ligne 27 fait référence a :
    donc essaye de revoir cette ligne en la désactivant pour vérifier
    C'est une erreur de copie, sur notepad++, c'est bien la ligne copiée en rouge ici qui pose problème.

    Merci quand même.

  8. #8
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut
    J'avoue qu'il y a pas mal de problèmes dans la base de la programmation mais j'avoue aussi ne pas avoir vraiment l'envie de tout refaire !!!

    D'après ce que j'ai compris suite à plusieurs essais, c'est que ma boucle tourne jusqu'à ce qu'une case du tableau soit vide, or comme aucune case du tableau n'est vide, la boucle tourne donc jusqu'à dépasser la taille du tableau, c'est pourquoi, en testant une case qui n'existe pas, j'obtiens forcément une erreur !

    J'aimerai donc tester la taille de mon tableau.

    Si j'ai un tableau : $tab[][];
    et que je fait : sizeof($tab); est-ce que j'obtient le nombre de cases de la première dimension ?
    et si je fait : sizeof($tab[0]); est-ce que j'obtient le nombre de cases de la seconde dimension de mon tableau ?

    Merci pour toutes vos réponses !

  9. #9
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut résultat tableau
    Voici ce qui se trouve dedans :
    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
     
    array
      0 => 
        array
          0 => string 'AbsHop' (length=6)
          1 => string '1' (length=1)
          2 => string '2011' (length=4)
          3 => string '07' (length=2)
          4 => string '09' (length=2)
          5 => string 'AbsPrevu' (length=8)
          6 => string '1' (length=1)
          7 => string '2011' (length=4)
          8 => string '07' (length=2)
          9 => string '10' (length=2)
          10 => string 'Abs' (length=3)
          11 => string '2' (length=1)
          12 => string '2011' (length=4)
          13 => string '07' (length=2)
          14 => string '09' (length=2)
          15 => string 'RepasFroid' (length=10)
          16 => string '2' (length=1)
          17 => string '2011' (length=4)
          18 => string '07' (length=2)
          19 => string '10' (length=2)
          20 => string '0' (length=1)
          21 => string '3' (length=1)
          22 => string '2011' (length=4)
          23 => string '07' (length=2)
          24 => string '09' (length=2)
          25 => string '0' (length=1)
          26 => string '3' (length=1)
          27 => string '2011' (length=4)
          28 => string '07' (length=2)
          29 => string '10' (length=2)
          30 => string '0' (length=1)
          31 => string '4' (length=1)
          32 => string '2011' (length=4)
          33 => string '07' (length=2)
          34 => string '09' (length=2)
          35 => string '0' (length=1)
          36 => string '4' (length=1)
          37 => string '2011' (length=4)
          38 => string '07' (length=2)
          39 => string '10' (length=2)
          40 => string '0' (length=1)
          41 => string '5' (length=1)
          42 => string '2011' (length=4)
          43 => string '07' (length=2)
          44 => string '09' (length=2)
          45 => string '0' (length=1)
          46 => string '5' (length=1)
          47 => string '2011' (length=4)
          48 => string '07' (length=2)
          49 => string '10' (length=2)
          50 => string '0' (length=1)
          51 => string '6' (length=1)
          52 => string '2011' (length=4)
          53 => string '07' (length=2)
          54 => string '09' (length=2)
          55 => string '0' (length=1)
          56 => string '6' (length=1)
          57 => string '2011' (length=4)
          58 => string '07' (length=2)
          59 => string '10' (length=2)
          60 => string '0' (length=1)
          61 => string '7' (length=1)
          62 => string '2011' (length=4)
          63 => string '07' (length=2)
          64 => string '09' (length=2)
          65 => string '0' (length=1)
          66 => string '7' (length=1)
          67 => string '2011' (length=4)
          68 => string '07' (length=2)
          69 => string '10' (length=2)
          70 => string '0' (length=1)
          71 => string '8' (length=1)
          72 => string '2011' (length=4)
          73 => string '07' (length=2)
          74 => string '09' (length=2)
          75 => string '0' (length=1)
          76 => string '8' (length=1)
          77 => string '2011' (length=4)
          78 => string '07' (length=2)
          79 => string '10' (length=2)
          80 => string '0' (length=1)
          81 => string '9' (length=1)
          82 => string '2011' (length=4)
          83 => string '07' (length=2)
          84 => string '09' (length=2)
          85 => string '0' (length=1)
          86 => string '9' (length=1)
          87 => string '2011' (length=4)
          88 => string '07' (length=2)
          89 => string '10' (length=2)
          90 => string '0' (length=1)
          91 => string '10' (length=2)
          92 => string '2011' (length=4)
          93 => string '07' (length=2)
          94 => string '09' (length=2)
          95 => string '0' (length=1)
          96 => string '10' (length=2)
          97 => string '2011' (length=4)
          98 => string '07' (length=2)
          99 => string '10' (length=2)
          100 => string '0' (length=1)
          101 => string '11' (length=2)
          102 => string '2011' (length=4)
          103 => string '07' (length=2)
          104 => string '09' (length=2)
          105 => string '0' (length=1)
          106 => string '11' (length=2)
          107 => string '2011' (length=4)
          108 => string '07' (length=2)
          109 => string '10' (length=2)
          110 => string '0' (length=1)
          111 => string '12' (length=2)
          112 => string '2011' (length=4)
          113 => string '07' (length=2)
          114 => string '09' (length=2)
          115 => string '0' (length=1)
          116 => string '12' (length=2)
          117 => string '2011' (length=4)
          118 => string '07' (length=2)
          119 => string '10' (length=2)
          120 => string '0' (length=1)
          121 => string '13' (length=2)
          122 => string '2011' (length=4)
          123 => string '07' (length=2)
          124 => string '09' (length=2)
          125 => string '0' (length=1)
          126 => string '13' (length=2)
          127 => string '2011' (length=4)
          more elements...
    Okay, c'est vraiment moche comme tableau ...

  10. #10
    Membre du Club
    Femme Profil pro
    Consultant informatique
    Inscrit en
    Décembre 2011
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 42
    Localisation : France, Oise (Picardie)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Décembre 2011
    Messages : 26
    Points : 51
    Points
    51
    Par défaut
    et si tu remplaces ta condition d’arrêt de la boucle par quelque chose qui ressemble à isset($Jourtransmid[0][5*$boucletableau]) ça devrai tester l’existence de la case.

  11. #11
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2011
    Messages : 18
    Points : 16
    Points
    16
    Par défaut
    Génial, c'est ça !!!

    Merci beaucoup.

  12. #12
    Expert éminent sénior
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Points : 16 545
    Points
    16 545
    Billets dans le blog
    12
    Par défaut
    Tu as aussi la possibilité de modifier un peu l'en-tête de la boucle ainsi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    set_time_limit(25);
    $nbDim2 = count($Jourtransmid[0]);
    for($boucletableau = 0; $boucletableau < $nbDim2; $boucletableau += 5) { ... }
    Et tu peux retirer partout le 5*.
    Fais bien attention à ce que tous les tableaux aient bien les même dimensions.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Erreur php : "Notice: Undefined offset: 1"
    Par bobette16 dans le forum Langage
    Réponses: 3
    Dernier message: 08/04/2013, 09h44
  2. Réponses: 9
    Dernier message: 18/05/2008, 12h06
  3. [PHP-JS] Problème Notice: Undefined index
    Par Sniper94-2 dans le forum Langage
    Réponses: 1
    Dernier message: 19/04/2007, 16h45
  4. erreur: "Notice: Undefined offset:"
    Par Sh1v3r dans le forum Langage
    Réponses: 2
    Dernier message: 17/06/2006, 22h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo