News:

Wondering if this will always be free?  See why free is better.

Main Menu

double ternary trouble

Started by 127.0.0.1, September 13, 2004, 11:39:41 AM

Previous topic - Next topic

127.0.0.1

'href' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload']) ? $scripturl . '?action=dlattach;id=' . $profile['ID_ATTACH'] . ';type=avatar' : '') : ''),

Parse error: parse error, unexpected ','

i just cant get that block of code to work and it doesnt help that my mind is mush right now. it's a new key i am adding after the 'name' key in the avatar array in load.php. i'm making it so i have an array that holds url without any html.

[Unknown]

Quote from: 127.0.0.1 on September 13, 2004, 11:39:41 AM
'href' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload']) ? $scripturl . '?action=dlattach;id=' . $profile['ID_ATTACH'] . ';type=avatar' : '') : ''),

Parse error: parse error, unexpected ','

i just cant get that block of code to work and it doesnt help that my mind is mush right now. it's a new key i am adding after the 'name' key in the avatar array in load.php. i'm making it so i have an array that holds url without any html.

If it's complicated, break it up:

'href' =>

$profile['avatar'] == ''
   ?
      ($profile['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload'])
         ?
            $scripturl . '?action=dlattach;id=' . $profile['ID_ATTACH'] . ';type=avatar'
         :
            ''
      )
   :
''
),


See the problem?  Here, I'll make it clearer:

'href' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload']) ? $scripturl . '?action=dlattach;id=' . $profile['ID_ATTACH'] . ';type=avatar' : '') : ''
),


Okay, I'll just tell you.  It's the extra ) at the end.

-[Unknown]

Advertisement: