NameSilo

[Resolved] Quick Question, Probably a simple fix

Spaceship Spaceship
Watch

The Equivocate

Established Member
Impact
13
Quick Question, Probably a simple fix

Here is the code I have now:

Code:
if (in_array($vbulletin->userinfo['usergroupid'], array(2)) || (in_array($vbulletin->userinfo['membergroupids'], array(1))))
{ 
$styleid = 1; 
}

What I want to do is change the $styleid to include more than one number, so I tried:

$styleid = 1,2,3;

but that gave me a bunch of errors. So how would I have to change it to be able to include an array of numbers?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
What are you looking for?

$styleid = "1,2,3,4,5";

Will work, without the " it won't. Or if you want a array

$styleid = array(1,2,3,4,5,6,7);

$styleid[0] == 1;
^

- Steve
 
Last edited:
0
•••
It's funny that in your 'if' statement you create an array of a single number, just so that you can use 'in_array' with a value (instead of just comparing the values directly), twice, and yet for some reason you can't work out how to create an array for your styleid :)

Anyway:
$styleid = array(1, 2, 3);

is what you're after...

iNod said:
$styleid['0'] == 1;

Please tell me those single quotes were a mistype. If you want to use numbers, use numbers: don't convert them to strings then hope that PHP will convert it correctly because there are a number of times that it doesn't.

In this instance, use:
$styleid[0] == 1;

instead of:
$styleid['0'] == 1;
 
0
•••
Happy now? lol, I see no reason in you needing to post that.. But oh well I fixed it :)

Plus I see absolutly no reason to attack this member verbally, so please do not post such comments again. He might be new to programming, so please edit your post and remove those insulting comments..

- Steve
 
0
•••
Sorry... I didn't mean to offend, but I can't say there was no reason for it. The code was wrong. Although it wouldn't fail, it was still wrong. Again, I didn't mean to offend, but using strings to represent numbers is just something that should not be done as it will cause problems in certain (not exactly 'edge') cases. Like I said, numbers are numbers, not strings and to use them as strings will cause problems. No, not in this instance but it's still incorrect.

Now, regarding the 'attack'. Where is it? I see some lighthearted jabbing at the start but it's certainly no attack! Besides that, part of the reason I wrote it was to also show that if you think more about what you're doing then sometimes the answer is right there in front of you.

I'm sorry if it was taken offensively, but it was definitely not intended as such. In fact, I thought better of what I was going to originally write so as to only imply that he already knows how to do it and that's basically my point: his code shows that he knows how to do it! Maybe he's just not confident enough and the off the cuff comment was trying to tell him so...
 
0
•••
The reason I asked is because I didn't write this code - it's part of a hack for vBulletin that forces certain skins on certain usergroups, but I want Guests (group 1) to have all the skins theoretically available to them, and then defined via the url (index.php?styleid=3 for example). So everything there was previously written by someone else, so if you'd like, I can point you to the thread at vb.org so you can attack him directly. The reason there's an array for a single number is because the hack originally allowed you to define a skin for multiple primary usergroups and then secondary usergroups.

Dunno why I didn't try the quote thing, but when I made the original (wrong) change, I messed up the forum so badly I couldn't even log into my Admin CP to disable the plugin.
 
0
•••
TwistMyArm said:
Sorry... I didn't mean to offend, but I can't say there was no reason for it. The code was wrong. Although it wouldn't fail, it was still wrong. Again, I didn't mean to offend, but using strings to represent numbers is just something that should not be done as it will cause problems in certain (not exactly 'edge') cases. Like I said, numbers are numbers, not strings and to use them as strings will cause problems. No, not in this instance but it's still incorrect.

Now, regarding the 'attack'. Where is it? I see some lighthearted jabbing at the start but it's certainly no attack! Besides that, part of the reason I wrote it was to also show that if you think more about what you're doing then sometimes the answer is right there in front of you.

I'm sorry if it was taken offensively, but it was definitely not intended as such. In fact, I thought better of what I was going to originally write so as to only imply that he already knows how to do it and that's basically my point: his code shows that he knows how to do it! Maybe he's just not confident enough and the off the cuff comment was trying to tell him so...

Thats all I ask :) Thank you. Sorry you are right though in that matter I should not have done '1'.

Does that answer your question The Equivocate?

- Steve
 
0
•••
Tried both those; giving me a vBulletin database error, so perhaps this is a question better asked at the vbulletin support forums.

Ha, can't believe I didn't think of this before - I just removed that section of the code that defines the skin for guests, meaning guests could use any skin... and it works. Thanks for all your help though, but I guess the easiest solution is the one I should try first haha.
 
Last edited:
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back