omesa Posted September 29, 2006 Share Posted September 29, 2006 Hello guys, I have a problem with the code below. The script is meant to insert the values collected from a form and be inserted into two tables namely the client table(main) and a clientchild table(child) repectively.The members's values are inserted well but the problem is that the clientchild's values aren't added, but when I interchange the codes, they are added to the child table and vis a vis.any help will be appreciated.thank you in advance.here's the code<html><head><title>insert</title></head><body><?phpglobal $Names,$Kounta; $new_name = addslashes('$Names'); $new_kounta = addslashes('$Kounta'); $conn = mysql_connect("localhost", "root", "")or die("Can't connect"); mysql_select_db("myndb",$conn) or die("Can't select!");//insert into main client table$squery = "insert into client(id,Names) values('NULL', '$Names')";$result = mysql_query($squery, $conn);if(isset($id)){ //get user id $user_id = mysql_insert_id($conn); //insert into clientchild table $squery = "insert into clientchild values('$Kounta', $user_id)"; $result = mysql_query($squery,$conn);}?></body></html> Link to comment https://forums.phpfreaks.com/topic/22504-inserting-into-multiple-tables/ Share on other sites More sharing options...
printf Posted September 29, 2006 Share Posted September 29, 2006 Where is [b]$id[/b], being set?me! Link to comment https://forums.phpfreaks.com/topic/22504-inserting-into-multiple-tables/#findComment-100901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.