I want to add data to different tables
Fermé
ssendu
Messages postés
6
Statut
Membre
-
blux Messages postés 4928 Date d'inscription Statut Modérateur Dernière intervention -
blux Messages postés 4928 Date d'inscription Statut Modérateur Dernière intervention -
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
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:
- I want to add data to different tables
- Qwerty to azerty - Guide
- App data - Guide
- I o on off ✓ - Forum Loisirs / Divertissements
- Reboot to bootloader - Guide
- Video to video - Télécharger - Conversion & Codecs
7 réponses
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
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
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
}
?>
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
}
?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Please can any one help on debugging this code and figure out what is the problem!!!!
:(
Thanks in advance
:(
Thanks in advance
I don't see any problem in your code :-(
Which data is not inserted ? The second and the third or only the third one ?
Which data is not inserted ? The second and the third or only the third one ?
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
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