View Full Version : What is wrong with this?
Scrub
03-29-2004, 01:22 PM
I've tried several diff ways to get this to work, but no luck with any. :ermm:
if ($userinfo['usergroupid'] == 1 && 3 && 4 && 8 && 9)
{
$show['link'] = false;
}
else
{
$show['link'] = true;
}
assassingod
03-29-2004, 01:27 PM
if (in_array($bbuserinfo['usergroupid'], 1,3,4,8,9)
{
$show['link'] = false;
}
else
{
$show['link'] = true;
}
That'll do it:)
Scrub
03-29-2004, 01:37 PM
Parse error: parse error, unexpected '{' in ***** on line 487
On line 487 is the { below the if in the code you posted. :(
Dean C
03-29-2004, 02:08 PM
Steve just forgot a trailing bracket and to actualy have an array ;) :)
Use this it's more efficient:
if (in_array($bbuserinfo['usergroupid'], array(1,3,4,8,9)))
{
$show['link'] = false;
}
else
{
$show['link'] = true;
}
filburt1
03-29-2004, 02:11 PM
If you are using vB3, always prefer is_member_of() over a check of the usergroupid key. This will, among other things, take additional usergroups into effect (not just the primary usergroup).
assassingod
03-29-2004, 02:58 PM
Steve just forgot a trailing bracket and to actualy have an array
Whoops:)
Scrub
03-29-2004, 03:34 PM
Thanks guys! :D
Filburt1, where would that go? Kind of a newbie in vB3 code :speechless:
Gary King
03-29-2004, 07:48 PM
Thanks guys! :D
Filburt1, where would that go? Kind of a newbie in vB3 code :speechless:
if (is_member_of($bbuserinfo, 1, 3, 4, 8, 9));
{
// etc.
}
Scrub
03-29-2004, 09:26 PM
Thank you! :D
Scrub
03-31-2004, 11:41 PM
Instead of making another thread, I'll post in this one. :D. Anyways, I am stuck yet again and on something that I thought would've been easy to do. :x.
Anyways, I am trying to achive something like member.php does, but no luck in making it work. I've scanned countless files trying almsot everything. LOL. But I need to show a username according to the userid, hence like the member.php file. Thanks in advanced. :)
Gary King
03-31-2004, 11:50 PM
Instead of making another thread, I'll post in this one. :D. Anyways, I am stuck yet again and on something that I thought would've been easy to do. :x.
Anyways, I am trying to achive something like member.php does, but no luck in making it work. I've scanned countless files trying almsot everything. LOL. But I need to show a username according to the userid, hence like the member.php file. Thanks in advanced. :)
$userinfo = fetch_userinfo($userid);
Then $userinfo is an array that has all the user info such as username, $userinfo['username'], etc.
Scrub
03-31-2004, 11:53 PM
You are the king! Thanks again! :D
Scrub
04-10-2004, 05:10 PM
Hello again! :)
I am currently trying to pull users from a specific usergroup out of the database. How would I go about doing that? This is the query I have. It only pulls one user out of the database. :(
$user = $DB_site->query_first("SELECT username FROM " . TABLE_PREFIX . " user WHERE usergroupid = 10");
Gary King
04-10-2004, 05:42 PM
Using the query_first only gets the first result; use query instead, but then you need to use $DB_site->fetch_array($user); in a while statement.
Scrub
04-13-2004, 10:34 AM
Hey,
I appreciate all the help, Gary W. But I am comfused on the while statement. I can't seem to figure out how you make one pretty much. I've looked through the PHP Manual, vBulletin Manual, searched several PHP sites and I am still baffled. I understand a little part I belive.
if ($_REQUEST['do'] == 'this_thing')
{
$users = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . " user AS user
WHERE user.usergroupid = 10
ORDER BY user.userid DESC
");
while ($user = $DB_site->fetch_array($users))
{
$username = fetch_musername($user);
eval('$main_template_bits = "' . fetch_template('main_template_bits') . '";');
}
eval('print_output("' . fetch_template('main_template') . '");');
}
Amd I on the right track? LOL. And I'd very much appriciate if you can make a working sample of a while statement that is in KISS format. :p. Again, I'd like to thank you and everyone else for all the help. :)
Gary King
04-13-2004, 10:09 PM
Try something like if ($_REQUEST['do'] == 'this_thing')
{
$users = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . " user AS user
WHERE user.usergroupid = 10
ORDER BY user.userid DESC
");
while ($user = $DB_site->fetch_array($users))
{
$username = fetch_musername($user);
eval('$main_template_bits .= "' . fetch_template('main_template_bits') . '";');
}
eval('print_output("' . fetch_template('main_template') . '");');
}
Then the main_template_bits would contain a <tr> most likely, or <br /> at the end.
Scrub
04-13-2004, 10:31 PM
Thanks man! Though I still don't see where I went wrong at though. Could've it have actually been the template where I forgot the <br /> tag? :confused:
Edit: The <br /> kind of messed up the layout. So I removed it and it still works. :).
Edit again: NEvermind. I missed a . in the eval part in the while query! :D
But thank you so much! :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.