Insert et foreach : Undefined offset: 0
Résolu
Sinistrus
Messages postés
1010
Date d'inscription
Statut
Membre
Dernière intervention
-
Sinistrus Messages postés 1010 Date d'inscription Statut Membre Dernière intervention -
Sinistrus Messages postés 1010 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous et meilleurs vœux pour cette année !
J'ai un soucis de
L'erreur se trouve sur cette ligne (126) :
Merci de votre aide et encore une fois, bonne et heureuse année !
J'ai un soucis de
undefined offsetdans mon code et je n'arrives pas à résoudre le problème. Pouvez-vous m'aider svp ?
$array_lib = !empty($_POST['Fr_Libelle']) ? $_POST['Fr_Libelle'] : array(); $array_qte = !empty($_POST['Fr_Quantite']) ? $_POST['Fr_Quantite'] : array(); $array_Poids = !empty($_POST['Fr_Poids']) ? $_POST['Fr_Poids'] : array(); $array_Poid_Total = !empty($_POST['Fr_Poid_Total']) ? $_POST['Fr_Poid_Total'] : array(); $array_pri = !empty($_POST['Fr_PrixUnit']) ? $_POST['Fr_PrixUnit'] : array(); $array_PrixTotal = !empty($_POST['Fr_PrixTotal']) ? $_POST['Fr_PrixTotal'] : array(); $array_rmz = !empty($_POST['Fr_Promo']) ? $_POST['Fr_Promo'] : array(); $Fr_Total_Produits = !empty($_POST['Fr_Total_Produits']) ? $_POST['Fr_Total_Produits'] : NULL; $Fr_Poids_Total = !empty($_POST['Fr_Poids_Total']) ? $_POST['Fr_Poids_Total'] : NULL; $Fr_Frais_Livraison = !empty($_POST['Fr_Frais_Livraison']) ? $_POST['Fr_Frais_Livraison'] : NULL; $Fr_Frais_Payement = !empty($_POST['Fr_Frais_Payement']) ? $_POST['Fr_Frais_Payement'] : NULL; $Fr_Net_A_Payer = !empty($_POST['Fr_Net_A_Payer']) ? $_POST['Fr_Net_A_Payer'] : NULL; $Fr_Adresse_Livraison = $ADRESSE; $Fr_Zone_Livraison = !empty($_POST['Fr_Zone_Livraison']) ? $_POST['Fr_Zone_Livraison'] : NULL; $Fr_Secteur = !empty($_POST['Fr_Secteur']) ? $_POST['Fr_Secteur'] : NULL; $Fr_Mode_Livraison = !empty($_POST['Fr_Mode_Livraison']) ? $_POST['Fr_Mode_Livraison'] : NULL; $Fr_Mode_Payement = !empty($_POST['Fr_Mode_Payement']) ? $_POST['Fr_Mode_Payement'] : NULL; try { $Fact_FA = $pdo - > prepare("INSERT INTO tb_shop_FA (NIC_Handle, Date, Reference, Libelle_TAG, Quantite, Poids, Poids_STotal, Prix_Unitaire, Prix_Total, Remise, Total_Produits, Grand_Total, Poids_Total, Frais_Livraison, Frais_Payement, Net_A_Payer, Adresse_Livraison, Zone_Livraison, Secteur, Mode_Livraison, Mode_Payement) VALUES(Fr_NIC_Handle,: Fr_Date,: Fr_Reference,: array_lib,: array_qte,: array_Poids,: array_Poid_Total,: array_pri,: array_PrixTotal,: array_rmz,: Fr_Total_Produits,: Fr_Grand_Total,: Fr_Poids_Total,: Fr_Frais_Livraison,: Fr_Frais_Payement,: Fr_Net_A_Payer,: Fr_Adresse_Livraison,: Fr_Zone_Livraison,: Fr_Secteur,: Fr_Mode_Livraison,: Fr_Mode_Payement)"); foreach($array_lib as $keyFA => $value) { if ($array_qte[$keyFA] < > 0) { $Fact_FA - > execute(array( "Fr_NIC_Handle" => $Fr_NIC_Handle, "Fr_Date" => $Fr_Date, "Fr_Reference" => $Fr_Reference, "array_lib" => $value, "array_qte" => $array_qte[$keyFA], "array_Poids" => $array_Poids[$keyFA], "array_Poid_Total" => $array_Poid_Total[$keyFA], "array_pri" => $array_pri[$keyFA], "array_PrixTotal" => $array_PrixTotal[$keyFA], "array_rmz" => $array_rmz[$keyFA], "Fr_Total_Produits" => $Fr_Total_Produits, "Fr_Grand_Total" => $Fr_Grand_Total, "Fr_Poids_Total" => $Fr_Poids_Total, "Fr_Frais_Livraison" => $Fr_Frais_Livraison, "Fr_Frais_Payement" => $Fr_Frais_Payement, "Fr_Net_A_Payer" => $Fr_Net_A_Payer, "Fr_Adresse_Livraison" => $Fr_Adresse_Livraison, "Fr_Zone_Livraison" => $Fr_Zone_Livraison, "Fr_Secteur" => $Fr_Secteur, "Fr_Mode_Livraison" => $Fr_Mode_Livraison, "Fr_Mode_Payement" => $Fr_Mode_Payement )); }}; } catch (PDOException $e) {echo "Erreur: ".$e - > getMessage();}
L'erreur se trouve sur cette ligne (126) :
if($array_qte[$keyFA] <> 0){et voici ce que print_r me donne :
Notice: Undefined offset: 0 in /home/sivopnetbi/www/shop/_shop-upp.php on line 126
Notice: Undefined offset: 1 in /home/sivopnetbi/www/shop/_shop-upp.php on line 126
Array ( [NumId] => 1 [action] => send [access] => Array ( [0] => home ) [Fr_Libelle] => Array ( [0] => EAU-DE-TOILETTE-AVIATOR-AUTHENTIC-VAPORISATEUR-DE-100ML [1] => DEODORANT-CHAIRMAN-BLUE-FLACON-DE-200ML ) [Fr_NumId] => Array ( [0] => 3 [1] => 20 ) [Fr_PrixUnit] => Array ( [0] => 6825 [1] => 1425 ) [Fr_Promo] => Array ( [0] => 15 [1] => 15 ) [Fr_PrixTotal] => Array ( [0] => 17403.75 [1] => 2422.5 ) [Fr_Poids] => Array ( [0] => 0.45542 [1] => 0.16167 ) [Fr_Poid_Total] => Array ( [0] => 1.36626 [1] => 0.32334 ) [Fr_Mode] => on [Fr_Total_Produits] => 19826.25 [Fr_Poids_Total] => 1.690 [Fr_Frais_Livraison] => 0 [Fr_Frais_Payement] => 0 [Fr_Net_A_Payer] => 19826.25 [Fr_Zone_Livraison] => SIVOP [Fr_Secteur] => [Fr_Mode_Livraison] => [Fr_Mode_Payement] => )
Merci de votre aide et encore une fois, bonne et heureuse année !
Configuration: Windows / Chrome 71.0.3578.98
A voir également:
- Insert et foreach : Undefined offset: 0
- Touche insert - Guide
- Disk boot failure insert system disk and press enter - Guide
- Activer touche insert sur ASUS UX32A - Forum Clavier
- Touche insert sur clavier portable hp ✓ - Forum Clavier
- Insert boot media in selected boot device and press a key ✓ - Forum PC portable
C'est cette ligne :
As-tu tenté un print_r sur les sources et lister les items de ton tableau "array_qte" ?
J'avais mis Fr_Quantite en disabled dans le html... voilà pourquoi il retournais cette erreur.
Le problème a été résolu et je te remercie encore une fois.