[php/SQL] Bonne requête qui ne fonctionne pas
Résolu
Rémy
-
Ohm-WorK Messages postés 1464 Date d'inscription Statut Contributeur Dernière intervention -
Ohm-WorK Messages postés 1464 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Je ne comprends pas ce qui m'arrive...
j'ai un requête relativement classique :
Lorsque je l'éxécute directement dans MySQL, elle fonctionne très bien.
Mais lorque je la lance via una page en php, ça ne fonctionne pas... Voici mon code php :
Quelqu'un saurait-il me dire pourquoi ??
Merci
Je ne comprends pas ce qui m'arrive...
j'ai un requête relativement classique :
CREATE TABLE Tempo ( TypeMaj char(1) NOT NULL, RefPartie1Old char(2) NULL, RefPartie2Old char(1) NULL, RefPartie3Old char(4) NULL, RefPartie4Old char(1) NULL, RefPartie1New char(2) NULL, RefPartie2New char(1) NULL, RefPartie3New char(4) NULL, RefPartie4New char(1) NULL, Type smallint NULL, Marque smallint NULL, Modele varchar(30) NULL, NumSerie varchar(30) NULL, Annee smallint NULL, DateAchat date NULL, Commercial varchar(2) NULL, ClientAchat varchar(30) NULL, Ville varchar(20) NULL, RC float NULL, VR float NULL, REO float NULL, PrixPieces float NULL, PrixStrict float NULL, PrixRevise float NULL, PrixGarantie float NULL, PrixMarchand float NULL, Vendu int NOT NULL ); LOAD DATA LOCAL INFILE 'monfichier.txt' INTO TABLE Tempo;
Lorsque je l'éxécute directement dans MySQL, elle fonctionne très bien.
Mais lorque je la lance via una page en php, ça ne fonctionne pas... Voici mon code php :
//connect $db = mysql_connect('localhost', 'root', '') or die('Erreur de connexion '.mysql_error()); mysql_select_db('xxx',$db) or die('Erreur de selection '.mysql_error()); mysql_query("CREATE TABLE Tempo ( TypeMaj char(1) NOT NULL, RefPartie1Old char(2) NULL, RefPartie2Old char(1) NULL, RefPartie3Old char(4) NULL, RefPartie4Old char(1) NULL, RefPartie1New char(2) NULL, RefPartie2New char(1) NULL, RefPartie3New char(4) NULL, RefPartie4New char(1) NULL, Type smallint NULL, Marque smallint NULL, Modele varchar(30) NULL, NumSerie varchar(30) NULL, Annee smallint NULL, DateAchat date NULL, Commercial varchar(2) NULL, ClientAchat varchar(30) NULL, Ville varchar(20) NULL, RC float NULL, VR float NULL, REO float NULL, PrixPieces float NULL, PrixStrict float NULL, PrixRevise float NULL, PrixGarantie float NULL, PrixMarchand float NULL, Vendu int NOT NULL ); LOAD DATA LOCAL INFILE 'monfichier.txt' INTO TABLE Tempo;");
Quelqu'un saurait-il me dire pourquoi ??
Merci
A voir également:
- [php/SQL] Bonne requête qui ne fonctionne pas
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Logiciel sql - Télécharger - Bases de données
- Ora-00933: la commande sql ne se termine pas correctement ✓ - Forum Oracle
- Quelle requête écrire pour demander au moteur de recherche de présenter de préférence les pages web traitant de tennis mais pas de tennis de table ✓ - Forum Java
5 réponses
Il n'y a pas de message d'erreur mais ma table 'Tempo' n'est pas créée. Pourtant, avec une éxecution directe dans MySQL, elle est créée... ;-?
Salut
As tu vraiment besoin de créer ta table à chaque affichage de ta page ??
Sinon, fais ca pour avoir le message d'erreur :
$sql = "CREATE TABLE Tempo (
TypeMaj char(1) NOT NULL,
RefPartie1Old char(2) NULL,
RefPartie2Old char(1) NULL,
RefPartie3Old char(4) NULL,
RefPartie4Old char(1) NULL,
RefPartie1New char(2) NULL,
RefPartie2New char(1) NULL,
RefPartie3New char(4) NULL,
RefPartie4New char(1) NULL,
Type smallint NULL,
Marque smallint NULL,
Modele varchar(30) NULL,
NumSerie varchar(30) NULL,
Annee smallint NULL,
DateAchat date NULL,
Commercial varchar(2) NULL,
ClientAchat varchar(30) NULL,
Ville varchar(20) NULL,
RC float NULL,
VR float NULL,
REO float NULL,
PrixPieces float NULL,
PrixStrict float NULL,
PrixRevise float NULL,
PrixGarantie float NULL,
PrixMarchand float NULL,
Vendu int NOT NULL
)";
$req = mysql_query($sql) or die (mysql_error());
Tchusss
As tu vraiment besoin de créer ta table à chaque affichage de ta page ??
Sinon, fais ca pour avoir le message d'erreur :
$sql = "CREATE TABLE Tempo (
TypeMaj char(1) NOT NULL,
RefPartie1Old char(2) NULL,
RefPartie2Old char(1) NULL,
RefPartie3Old char(4) NULL,
RefPartie4Old char(1) NULL,
RefPartie1New char(2) NULL,
RefPartie2New char(1) NULL,
RefPartie3New char(4) NULL,
RefPartie4New char(1) NULL,
Type smallint NULL,
Marque smallint NULL,
Modele varchar(30) NULL,
NumSerie varchar(30) NULL,
Annee smallint NULL,
DateAchat date NULL,
Commercial varchar(2) NULL,
ClientAchat varchar(30) NULL,
Ville varchar(20) NULL,
RC float NULL,
VR float NULL,
REO float NULL,
PrixPieces float NULL,
PrixStrict float NULL,
PrixRevise float NULL,
PrixGarantie float NULL,
PrixMarchand float NULL,
Vendu int NOT NULL
)";
$req = mysql_query($sql) or die (mysql_error());
Tchusss
ton code FONCTIONNE !!
Puis, j'ai fait une deuxième requête :
et ça marche alors pourquoi ça ne marchait pas avant ? mystère et boule de gomme...
Puis, j'ai fait une deuxième requête :
$sql="LOAD DATA LOCAL INFILE 'monfichier.txt' INTO TABLE Tempo;"; $req = mysql_query($sql) or die (mysql_error());
et ça marche alors pourquoi ça ne marchait pas avant ? mystère et boule de gomme...
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question