par
pauline » 20 mars 2011, 01:17
Bonjour, j'ai un problème que je n'arrive pas à résoudre... je ne comprend pas comment faire fonctionner une requête sql dans le code suivant :
Code : Tout sélectionner
if($type1 == 'engin')
{
mysqli_query("INSERT INTO flotte VALUES('','$findsect','$emat','$type1','$nom','$caracteristique','$imma','$etat','$position','$causeindispo','$entreeNTI','$sortieprevueNTI','$datenextvisite','$potentiel','$echeance','$prochaineIM','$aptitudeIM','$nom_mission')"); //18 variables au total :NE FONCTIONNE PAS
mysqli_query("INSERT INTO engin VALUES ('','','$findsect','$imma','$heuresm',NOW())"); //FONCTIONNE
}
else
...
La première requête INSERT ne fonctionne pas et je n'ai pas de message d'erreur.
La deuxième requête INSERT fonctionne très bien...
après avoir tenté toutes les syntaxes imaginables, j'en conclu que le problème est dans la base... les deux tables sont différentes... mais je ne comprends pas l'erreur...
Voici le code sql de ma table flotte :
Code : Tout sélectionner
CREATE TABLE IF NOT EXISTS `flotte` (
`idmac` int(10) unsigned NOT NULL AUTO_INCREMENT,
`section` varchar(10) NOT NULL,
`codeemat` int(10) NOT NULL,
`type1` char(20) NOT NULL,
`nom` char(15) NOT NULL,
`caracteristique` char(10) DEFAULT NULL,
`imma` char(10) NOT NULL,
`etat` char(15) NOT NULL,
`position` char(15) NOT NULL,
`causeindispo` char(15) DEFAULT NULL,
`entreeNTI` date DEFAULT NULL,
`sortieprevueNTI` date DEFAULT NULL,
`nextvisitetps` date DEFAULT NULL,
`potentiel` float(9,0) DEFAULT NULL,
`echeance` float(9,0) DEFAULT NULL,
`prochaineIM` date DEFAULT NULL,
`aptitudeIM` date NOT NULL,
`nom_mission` varchar(20) DEFAULT NULL,
PRIMARY KEY (`idmac`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Voici le code sql de ma table engin :
Code : Tout sélectionner
CREATE TABLE IF NOT EXISTS `engin` (
`ideng` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idmac` int(10) unsigned NOT NULL,
`section` varchar(10) NOT NULL,
`imma` varchar(20) DEFAULT NULL,
`heures` float(8,0) DEFAULT NULL,
`datemodif` datetime DEFAULT NULL,
PRIMARY KEY (`ideng`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
Merci d'avance pour votre aide.
Bonjour, j'ai un problème que je n'arrive pas à résoudre... je ne comprend pas comment faire fonctionner une requête sql dans le code suivant :
[code]
if($type1 == 'engin')
{
mysqli_query("INSERT INTO flotte VALUES('','$findsect','$emat','$type1','$nom','$caracteristique','$imma','$etat','$position','$causeindispo','$entreeNTI','$sortieprevueNTI','$datenextvisite','$potentiel','$echeance','$prochaineIM','$aptitudeIM','$nom_mission')"); //18 variables au total :NE FONCTIONNE PAS
mysqli_query("INSERT INTO engin VALUES ('','','$findsect','$imma','$heuresm',NOW())"); //FONCTIONNE
}
else
...
[/code]
La première requête INSERT ne fonctionne pas et je n'ai pas de message d'erreur.
La deuxième requête INSERT fonctionne très bien...
après avoir tenté toutes les syntaxes imaginables, j'en conclu que le problème est dans la base... les deux tables sont différentes... mais je ne comprends pas l'erreur...
Voici le code sql de ma table flotte :[code]
CREATE TABLE IF NOT EXISTS `flotte` (
`idmac` int(10) unsigned NOT NULL AUTO_INCREMENT,
`section` varchar(10) NOT NULL,
`codeemat` int(10) NOT NULL,
`type1` char(20) NOT NULL,
`nom` char(15) NOT NULL,
`caracteristique` char(10) DEFAULT NULL,
`imma` char(10) NOT NULL,
`etat` char(15) NOT NULL,
`position` char(15) NOT NULL,
`causeindispo` char(15) DEFAULT NULL,
`entreeNTI` date DEFAULT NULL,
`sortieprevueNTI` date DEFAULT NULL,
`nextvisitetps` date DEFAULT NULL,
`potentiel` float(9,0) DEFAULT NULL,
`echeance` float(9,0) DEFAULT NULL,
`prochaineIM` date DEFAULT NULL,
`aptitudeIM` date NOT NULL,
`nom_mission` varchar(20) DEFAULT NULL,
PRIMARY KEY (`idmac`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;[/code]
Voici le code sql de ma table engin : [code]
CREATE TABLE IF NOT EXISTS `engin` (
`ideng` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idmac` int(10) unsigned NOT NULL,
`section` varchar(10) NOT NULL,
`imma` varchar(20) DEFAULT NULL,
`heures` float(8,0) DEFAULT NULL,
`datemodif` datetime DEFAULT NULL,
PRIMARY KEY (`ideng`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;[/code]
Merci d'avance pour votre aide.