Jump to content

Recommended Posts

Hey guys

Ok i am having a bit of trouble i am getting a error in my php coding can you help please.

This is the error

Parse error: parse error, unexpected T_IF, expecting ')' in ***********************forums.php on line 33

This is the code
[code]if ($user[uRank==3]) {  // this is line 33
        echo;
                7 => 'Staff General',
                8 => 'Staff bug report');[/code]


Thanks for your time
Link to comment
https://forums.phpfreaks.com/topic/19121-php-error/
Share on other sites

Well, I don't really see what you want to accomplish with this code, but my observations:
1. the code for the if
[code]if ($user[uRank] ==3)[/code]
2. you do not close your opening brace
3. what does the empty echo do?
4. what are the key 7 and 8 assignments doing in the 'if' result?
5. your closing parenth does not have an opening parenth

Ronald  8)
Link to comment
https://forums.phpfreaks.com/topic/19121-php-error/#findComment-82700
Share on other sites

[quote]Well, I don't really see what you want to accomplish with this code, but my observations:
1. the code for the if

Code:
if ($user[uRank] ==3)2. you do not close your opening brace
3. what does the empty echo do?
4. what are the key 7 and 8 assignments doing in the 'if' result?
5. your closing parenth does not have an opening parenth
[/quote]

1. i dont understand what u mean.
2. there is a closing bracket i just didnt copy that far down in my code.
3. the echo is to echo the staff forums
4. there are 8 topics to my forum.
5. sorry but whats parenth mean?

more of my code to help you understand.

[code]        $forumz = array(1 => 'Announcements',
                        2 => 'General Discussion',
        3 => 'Newbie Help',
4 => 'Fun And Games',
        5 => 'Non-Game',
        6 => 'Game Help',
        if ($user[uRank==3]) {
        echo;
                7 => 'Staff General',
                8 => 'Staff bug report');
}[/code]

Edit... the if statement is so only staff with that urank can see the topics

Thanks
Link to comment
https://forums.phpfreaks.com/topic/19121-php-error/#findComment-82701
Share on other sites

I cannot find head or tail in your code, but my solution would be to define the array and to remove the entries if a user is not 3, with the following code:
[code]<?php
$forumz = array(1 => 'Announcements',
                2 => 'General Discussion',
  3 => 'Newbie Help',
  4 => 'Fun And Games',
  5 => 'Non-Game',
  6 => 'Game Help',
  7 => 'Staff General',
  8 => 'Staff bug report'
);
if ($user[uRank] != 3) {
  unset($forumz['7']);
  unset($forumz['8']);
}
?>[/code]

Ronald  8)
Link to comment
https://forums.phpfreaks.com/topic/19121-php-error/#findComment-82708
Share on other sites

or[code]
$forumz = array(1 => 'Announcements',
                      2 => 'General Discussion',
      3 => 'Newbie Help',
      4 => 'Fun And Games',
      5 => 'Non-Game',
      6 => 'Game Help');
if ($user[uRank==3]) {
  $forumz[7] = 'Staff General';
  $forumz[8] = 'Staff bug report';
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/19121-php-error/#findComment-83076
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.