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   -
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 92 Statut Membre 3
 
0
ssendu Messages postés 6 Statut Membre
 
Sorry, but what is that?? Can you please specify why the website is useful??
0
lecube Messages postés 327 Statut Membre 54
 
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 Statut Membre
 
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 Statut Membre
 
Please can any one help on debugging this code and figure out what is the problem!!!!

:(

Thanks in advance
0
lecube Messages postés 327 Statut Membre 54
 
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 4928 Date d'inscription   Statut Modérateur Dernière intervention   3 367
 
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