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 :

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000 [MySQL]


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2006
    Messages
    985
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Juillet 2006
    Messages : 985
    Par défaut Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000
    Bonjour,
    J'ai ce array :
    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
     
    $myArray = array (
        0 => array (
    		  'structure_id' => '160',
    		  'structure_libelle' => 'Cabinet',
    		  'structure_level' => '-1',
    		  'structure_login' => '16-1-160-1',
    		  'structure_pswd1' => 'iv0ih0e0',
    		  'sub' => NULL,
    		),
        1 => array (
    		  'structure_id' => '161',
    		  'structure_libelle' => 'Inspection Générale de l’Evaluation des Performances des Services',
    		  'structure_level' => '-1',
    		  'structure_login' => '16-1-161-1',
    		  'structure_pswd1' => '01fadaex',
    		  'sub' => array (
    						0 => array (
    								'structure_id' => '1',
    								'structure_libelle' => 'Délégation Départementale - Djérem',
    								'structure_level' => '2',
    								'structure_login' => '16-2-1-2',
    								'structure_pswd1' => 'wdhafmq5',
    								'sub' => NULL
    							),
    						1 => array (
    								'structure_id' => '1',
    								'structure_libelle' => 'Délégation Départementale - Djérem',
    								'structure_level' => '2',
    								'structure_login' => '16-2-1-2',
    								'structure_pswd1' => 'wdhafmq5',
    								'sub' => array (
    											0 => array (
    													'structure_id' => '1',
    													'structure_libelle' => 'Délégation Départementale - Djérem',
    													'structure_level' => '2',
    													'structure_login' => '16-2-1-2',
    													'structure_pswd1' => 'wdhafmq5',
    													'sub' => NULL
    												)
    										)
    							)
    					)
    		),
        2 => array (
    		  'structure_id' => '162',
    		  'structure_libelle' => 'Inspection Générale de l’Evaluation du Fonctionnement des Services',
    		  'structure_level' => '-1',
    		  'structure_login' => '16-1-162-1',
    		  'structure_pswd1' => '8kyalmle',
    		  'sub' => NULL,
    		)
    );
    Je le parcours ainsi pour faire des insertions dans ma bdd
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    function remplir_dbb($array) {
    	foreach ($array as $data) {
    		foreach ($data as $value) {
    			insertValidateur($value);
    			if ( isset($value['sub']) && is_array($value['sub']) ) {
    				remplir_dbb($value['sub']);
    			}
    		}
    	}
    }
     
    remplir_dbb($myArray);
    Message d'erreur :
    ( ! ) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'login' cannot be null' in I:\wamp2\www\validation\index.php on line 285
    ( ! ) PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'login' cannot be null in I:\wamp2\www\validation\index.php on line 285
    D'où pourrait provenir cette erreur ?
    [EDIT]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    function insertValidateur($array) {
    	global $db;
    	$return = false;
    	$sql = 'INSERT INTO validateurs (login, pswd, salt) VALUES (:login, :pswd, :salt)';
    	$statement = $db->prepare($sql);
    	if ( $statement->execute(array(':login' => $array['structure_login'], ':pswd' => $array['structure_pswd'], ':salt' => $array['structure_salt'])) ) { $return = true;}
    	return $return;
    }
    Merci d'avance...

  2. #2
    Expert confirmé

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Par défaut
    fait un

  3. #3
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2006
    Messages
    985
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Juillet 2006
    Messages : 985
    Par défaut
    Citation Envoyé par stealth35 Voir le message
    fait un
    array
    0 =>
    array
    'structure_id' => string '160' (length=3)
    'structure_libelle' => string 'Cabinet' (length=7)
    'structure_level' => string '-1' (length=2)
    'structure_login' => string '16-1-160-1' (length=10)
    'structure_pswd1' => string 'iv0ih0e0' (length=8)
    'sub' => null
    1 =>
    array
    'structure_id' => string '161' (length=3)
    'structure_libelle' => string 'Inspection Générale de l’Evaluation des Performances des Services' (length=69)
    'structure_level' => string '-1' (length=2)
    'structure_login' => string '16-1-161-1' (length=10)
    'structure_pswd1' => string '01fadaex' (length=8)
    'sub' =>
    array
    0 =>
    array
    ...
    1 =>
    array
    ...
    2 =>
    array
    'structure_id' => string '162' (length=3)
    'structure_libelle' => string 'Inspection Générale de l’Evaluation du Fonctionnement des Services' (length=70)
    'structure_level' => string '-1' (length=2)
    'structure_login' => string '16-1-162-1' (length=10)
    'structure_pswd1' => string '8kyalmle' (length=8)
    'sub' => null
    Voilà le résultat

  4. #4
    Expert confirmé

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Par défaut
    le $array de insertValidateur

  5. #5
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2006
    Messages
    985
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Juillet 2006
    Messages : 985
    Par défaut
    Citation Envoyé par stealth35 Voir le message
    le $array de insertValidateur
    insertValidateur($array) recoit bien un array qui possède bien les propriété structure_login, structure_pswd, structure_salt.

    franchement je ne comprends pas le problème.

  6. #6
    Expert confirmé

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Par défaut
    Citation Envoyé par okoweb Voir le message
    insertValidateur($array) recoit bien un array qui possède bien les propriété structure_login, structure_pswd, structure_salt.

    franchement je ne comprends pas le problème.
    bah montre

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 08/04/2015, 20h59
  2. Réponses: 2
    Dernier message: 30/03/2015, 11h18
  3. Réponses: 1
    Dernier message: 07/08/2012, 23h48
  4. [MySQL] Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002]
    Par -Fly- dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 11/04/2011, 11h18
  5. Réponses: 3
    Dernier message: 04/04/2011, 17h32

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