Page 1 of 1
Variable only being used once
Posted: Sun Nov 19, 2006 3:17 pm
by tristanlee85
Code: Select all
//Create the forum
$sql = "INSERT INTO phpbb_forums
VALUES ('$forum_id', '1', '$new_member', '$description', '0', '$new_forum_order', '0', '0', '0', '', '0', '0', '0', '3', '1', '1', '3', '3', '3', '1', '1', '1', '-1', '1', '29')";
mysql_query($sql);
//Set the group values
$sql = "INSERT INTO phpbb_groups
VALUES ('$group_id', '1', '', 'Personal User', '0', '1')";
mysql_query($sql);
$sql = "INSERT INTO phpbb_user_groups
VALUES ('$group_id', '$user_id', '0')";
mysql_query($sql);
//Make the user moderator of his/her forum
$sql = "INSERT INTO phpbb_auth_access
VALUES ('$group_id', '$forum_id', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0')";
mysql_query($sql);
The variable
$group_id is to be used in 3 different queries. When I run the script, it's used in the first query, but then in the last 2 queries, it inserts 0 instead of the $group_id variable. Why is this?
Posted: Sun Nov 19, 2006 3:22 pm
by hawleyjr
Echo out each query....
Posted: Sun Nov 19, 2006 3:29 pm
by tristanlee85
I don't understand what you are saying.
Posted: Sun Nov 19, 2006 3:31 pm
by Luke
he means echo out your queries... not as a solution, but to help us troubleshoot the problem...
Code: Select all
//Create the forum
$sql = "INSERT INTO phpbb_forums
VALUES ('$forum_id', '1', '$new_member', '$description', '0', '$new_forum_order', '0', '0', '0', '', '0', '0', '0', '3', '1', '1', '3', '3', '3', '1', '1', '1', '-1', '1', '29')";
echo $sql . "<BR>";
mysql_query($sql);
//Set the group values
$sql = "INSERT INTO phpbb_groups
VALUES ('$group_id', '1', '', 'Personal User', '0', '1')";
mysql_query($sql);
echo $sql . "<BR>";
$sql = "INSERT INTO phpbb_user_groups
VALUES ('$group_id', '$user_id', '0')";
mysql_query($sql);
echo $sql . "<BR>";
//Make the user moderator of his/her forum
$sql = "INSERT INTO phpbb_auth_access
VALUES ('$group_id', '$forum_id', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0')";
echo $sql . "<BR>";
mysql_query($sql);
Re: Variable only being used once
Posted: Sun Nov 19, 2006 3:31 pm
by hawleyjr
Code: Select all
//Set the group values
$sql = "INSERT INTO phpbb_groups
VALUES ('$group_id', '1', '', 'Personal User', '0', '1')";
mysql_query($sql);
echo '<hr>' . $qry;
$sql = "INSERT INTO phpbb_user_groups
VALUES ('$group_id', '$user_id', '0')";
mysql_query($sql);
echo '<hr>' . $qry;
//Make the user moderator of his/her forum
$sql = "INSERT INTO phpbb_auth_access
VALUES ('$group_id', '$forum_id', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0')";
mysql_query($sql);
echo '<hr>' . $qry;
Posted: Sun Nov 19, 2006 4:43 pm
by tristanlee85
Hmm. It just started working... not exactly sure what I changed. I echo'd it out like you said and the queries were right. I deleted a few records in the database and I think it got my counts off. That's why some of it was executing right and some wasn't. Thanks all.