Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: SinekSekiz - heinäkuu 24, 2007, 01:45:28 IP

Otsikko: Inserting one data to two different table and field..
Kirjoitti: SinekSekiz - heinäkuu 24, 2007, 01:45:28 IP
Hi

I have an on-line game and I would like to ad Alliance future in it. But I have a problem about inserting datas to 2 different table;

I need to get 3 input from the user. These are aLogin, aLogo, aTag after I get these 3 input I need to add all of them to alliance and aLogin to user.

I have tried many ways but last one is this;
//1th part
$query = "INSERT INTO `alliances` ";
$query .= "( `aLogin` , `aLogo` , `aTag` , `aID`) ";
$query .= "VALUES (\"$thealliance\", \"$thelogo\", \"$thetag\", \"$randcode\")";
$db->query($query);
$linsrt = mysql_insert_id();
//2nd part
$query2 = "INSERT INTO `users` ";
$query2 .= "( `uAlliance`) ";
$query2 .= "VALUES (\"$thealliance\")";
$db->query($query2);
$linsrt = mysql_insert_id();

I definitely am doing something wrong. Because the first part works as it should be but second part does not enter the value to the second table.
Otsikko: Re: Inserting one data to two different table and field..
Kirjoitti: SinekSekiz - heinäkuu 26, 2007, 11:16:35 AP
Sorry guys I have solved problem. It was a simple syntax error in the form.

Thank you.