View Full Version : help with PHP
geniuscrew
05-15-2002, 04:08 PM
Hi
I'm trying to modify neo's 'admin avatar size' hack.
I'm changing it so that mods have different sizes to admins.
Could someone please tell me what is wrong this code (I'm gussing it's the wasy I structured it:
if ($bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==7 || $bbuserinfo[usergroupid]==5) {
$customtext = "Note: the maximum size of your custom image is $amw in width by $amh in height or $amfs bytes (whichever is smaller).";
} else {
$customtext = "Note: the maximum size of your custom image is $mmw in width by $mmh in height or $mmfs bytes (whichever is smaller).";
} else {
$customtext = "Note: the maximum size of your custom image is $avatarmaxdimension by $avatarmaxdimension pixels or $avatarmaxsize bytes (whichever is smaller).";
}
Thanx
Xenon
05-15-2002, 04:29 PM
you cannot make a second else clause after one.
you must make it more specific like this:
if ($bbuserinfo[usergroupid]==7) {
$customtext = "Note: the maximum size of your custom image is $amw in width by $amh in height or $amfs bytes (whichever is smaller).";
} else {
if ($bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==5) {
$customtext = "Note: the maximum size of your custom image is $mmw in width by $mmh in height or $mmfs bytes (whichever is smaller).";
} else {
$customtext = "Note: the maximum size of your custom image is $avatarmaxdimension by $avatarmaxdimension pixels or $avatarmaxsize bytes (whichever is smaller).";
}
}
this should work
geniuscrew
05-15-2002, 04:44 PM
Thanx xenon, that works :)
Now i've applied the same format to a piece of code to get this :
if ($bbuserinfo[usergroupid]==6) {
if ($filesize>$amfs) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
}
} else {
if ($bbuserinfo[usergroupid]==7 || $bbuserinfo[usergroupid]==5) {
if ($filesize>$mmfs) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
}
} else {
if ($filesize>$avatarmaxsize) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
}
}
Is it correct?
Thanx again
Xenon
05-15-2002, 04:53 PM
this code is correct, but you have forgotten an } at the end.
i cant see any other error
geniuscrew
05-15-2002, 04:58 PM
Thanx that works too but one more error lol
towards the end at about line 1549
[PHP]
}
?>
[/PHP
There is another error.
Thankyou very much for your help
Xenon
05-15-2002, 05:02 PM
what is the errormessage exactly?
errors in the last lines ar often } too much or too less :)
perhaps you haven't forgotten this } of my last post in your code, but have forgotten it in your post here :)
geniuscrew
05-15-2002, 07:07 PM
it's not working still :(
The message i get is:
Parse error: parse error in /home/charmed/public_html/forums/member.php on line 1550
geniuscrew
05-15-2002, 07:49 PM
Actually i got it working now :)
Vielen danken fur deine Hilfe Xenon!
Bye!
Xenon
05-15-2002, 08:02 PM
fine :)
i'm glad i could help you :)
if ($bbuserinfo[usergroupid]==6) {
if ($filesize>$amfs) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
}
} elseif ($bbuserinfo[usergroupid]==7 || $bbuserinfo[usergroupid]==5) {
if ($filesize>$mmfs) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
} elseif ($filesize>$avatarmaxsize) {
eval("standarderror(\"".gettemplate("error_avatartoobig")."\");");
// file size too big
exit;
}
}
You could have used a elseif statement
Xenon
05-16-2002, 08:49 AM
yeah, thats another possibility, but i don't like elseifs ;)
i think the structure of normal if-else-clauses looks better :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.