I want to add data to different tables

Fermé
ssendu Messages postés 6 Date d'inscription dimanche 26 juillet 2009 Statut Membre Dernière intervention 2 septembre 2009 - 27 juil. 2009 à 17:12
blux Messages postés 26803 Date d'inscription dimanche 26 août 2001 Statut Modérateur Dernière intervention 21 avril 2025 - 27 juil. 2009 à 20:32
Bonjour,

I m building an intranet, I have a form that and I want to insert the data I get from it to different tables in the same database. The problem I have is when I write the queries, ONLY the data of the first query is inserted in the database. The following queries are discarded.... Does ant one of you have an idea about how to solve the problem??? pleaaaaaaase help

:(


Thanks in advance
A voir également:

7 réponses

necrowater1997 Messages postés 81 Date d'inscription jeudi 2 juillet 2009 Statut Membre Dernière intervention 16 mars 2010 3
27 juil. 2009 à 17:13
0
ssendu Messages postés 6 Date d'inscription dimanche 26 juillet 2009 Statut Membre Dernière intervention 2 septembre 2009
27 juil. 2009 à 17:16
Sorry, but what is that?? Can you please specify why the website is useful??
0
lecube Messages postés 304 Date d'inscription samedi 14 mars 2009 Statut Membre Dernière intervention 13 avril 2010 54
27 juil. 2009 à 17:18
Hy,

I think it would be better from you to write the part of you code where you have your problem. It is not so easy to undertsand without any lines ... :-(
Regards
0
ssendu Messages postés 6 Date d'inscription dimanche 26 juillet 2009 Statut Membre Dernière intervention 2 septembre 2009
27 juil. 2009 à 17:25
OK thanks aloot lecube.

Here is the code:
<?php

$conn= mysql_connect("localhost", "root", ""); // Connexion à MySQL
mysql_select_db("test"); // Sélection de la base coursphp
if (isset($_POST['Submit']))
{
$a = $_POST['client'];
$b = $_POST['env'];
$c = $_POST['machine'];


$result1= mysql_query("INSERT INTO client(nom_client) VALUES ('$a')");
$exec= mysql_query($result1, $conn);


$code_client=mysql_insert_id();

printf("le dernier ID1 %d\n", mysql_insert_id());

$result3=mysql_query("INSERT INTO machine(Nom_machine) VALUES ('$c')");
$exec= mysql_query($result3,$conn);


$id_machine=mysql_insert_id();

printf("le dernier ID2 %d\n", mysql_insert_id());

$result2= mysql_query("INSERT INTO environnement VALUES (NULL,'$b',".$code_client.",".$id_machine.")");
$exec= mysql_query($result2,$conn);

echo "\ndata2 inserted";
mysql_close($conn);

echo "\ndata inserted\n"; // Déconnexion de MySQL
}
?>
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
ssendu Messages postés 6 Date d'inscription dimanche 26 juillet 2009 Statut Membre Dernière intervention 2 septembre 2009
27 juil. 2009 à 17:38
Please can any one help on debugging this code and figure out what is the problem!!!!

:(

Thanks in advance
0
lecube Messages postés 304 Date d'inscription samedi 14 mars 2009 Statut Membre Dernière intervention 13 avril 2010 54
27 juil. 2009 à 20:00
I don't see any problem in your code :-(
Which data is not inserted ? The second and the third or only the third one ?
0
blux Messages postés 26803 Date d'inscription dimanche 26 août 2001 Statut Modérateur Dernière intervention 21 avril 2025 3 335
27 juil. 2009 à 20:32
Salut,

merci de poster ce message sur la version anglaise du site :
please open a new topic on the english version of this site :

http://en.kioskea.net/forum/forum-3-programming

I close this one. Je ferme
0