Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: WolfJ on August 20, 2021, 08:38:51 AM

Title: Syntax Error on Member List
Post by: WolfJ on August 20, 2021, 08:38:51 AM
I've got this error on the member list and I'm not sure what's caused. I've tried to uninstall the last couple of mods but still nothing. Any advice would be great thanks.

syntax error, unexpected '$context' (T_VARIABLE), expecting '('
Title: Re: Syntax Error on Member List
Post by: shadav on August 20, 2021, 09:22:26 AM
what mods have you installed that edited the memberlist files?
Title: Re: Syntax Error on Member List
Post by: vbgamer45 on August 20, 2021, 09:25:21 AM
Also attach your sources/memberlist.php
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 20, 2021, 03:56:09 PM
Quote from: shadav on August 20, 2021, 09:22:26 AMwhat mods have you installed that edited the memberlist files?

That's the issue, I don't remember what package I installed. Trying to look though all 41 now.

Quote from: vbgamer45 on August 20, 2021, 09:25:21 AMAlso attach your sources/memberlist.php

I've attached it below to this message.

Memberlist.php



Thanks for the help
Title: Re: Syntax Error on Member List
Post by: Shambles on August 20, 2021, 04:20:05 PM
There's nothing wrong with the file you attached (according to https://www.piliapp.com/php-syntax-check/)

Are there any further pointers in your error log that may help pinpoint the file & line number thats generating the error?
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 21, 2021, 03:10:34 PM
Quote from: Shambles on August 20, 2021, 04:20:05 PMThere's nothing wrong with the file you attached (according to https://www.piliapp.com/php-syntax-check/)

Are there any further pointers in your error log that may help pinpoint the file & line number thats generating the error?

Just gives me that one critical error in the logs. Nothing else about the member list.
Title: Re: Syntax Error on Member List
Post by: vbgamer45 on August 21, 2021, 03:14:07 PM
And it doesn't say the file or line number? in the error log???
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 21, 2021, 03:20:24 PM
This is all I see on the error log. Nothing else. I wish I knew what was causing this.

Member List Error.JPG
Title: Re: Syntax Error on Member List
Post by: shadav on August 21, 2021, 03:36:03 PM
the only thing in your source file that I see is the posts array commented out
not sure why though but um ok
/* 'posts' => array(
'label' => $txt['posts'],
'width' => '115',
'colspan' => '2',
'default_sort_rev' => true,
)*/

can you upload your Memberlist.template.php
Title: Re: Syntax Error on Member List
Post by: shadav on August 21, 2021, 03:39:43 PM
ok so I can't edit my post...
i think i see the problem ;)
since you commited out the posts array you need to change the array above it from ), to )
so right above what I posted above find that then directly above it
'registered' => array(
'label' => $txt['date_registered']
),
change to
'registered' => array(
'label' => $txt['date_registered']
)
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 23, 2021, 08:06:34 AM
Quote from: shadav on August 21, 2021, 03:36:03 PMthe only thing in your source file that I see is the posts array commented out
not sure why though but um ok
/* 'posts' => array(
'label' => $txt['posts'],
'width' => '115',
'colspan' => '2',
'default_sort_rev' => true,
)*/

can you upload your Memberlist.template.php

I have no idea what mod did this or why it's like if I'm honest but I can upload that file

Memberlist.template.php

Quote from: shadav on August 21, 2021, 03:39:43 PMok so I can't edit my post...
i think i see the problem ;)
since you commited out the posts array you need to change the array above it from ), to )
so right above what I posted above find that then directly above it
'registered' => array(
'label' => $txt['date_registered']
),
change to
'registered' => array(
'label' => $txt['date_registered']
)

I tried this fix but sadly it's still not working. Thanks for trying though!
Title: Re: Syntax Error on Member List
Post by: GL700Wing on August 23, 2021, 08:27:49 AM
I think I've found the problem on line 118 of your Memberlist.template.php

Find:
if $context['user']['is_admin'] && (!empty($member['post_percent']))
Replace With:
if ($context['user']['is_admin'] && !empty($member['post_percent']))
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 23, 2021, 12:48:52 PM
Quote from: GL700Wing on August 23, 2021, 08:27:49 AMI think I've found the problem on line 118 of your Memberlist.template.php

Find:
if $context['user']['is_admin'] && (!empty($member['post_percent']))
Replace With:
if ($context['user']['is_admin'] && !empty($member['post_percent']))

Thanks for your response. This has fixed that issue but has now given another error message.

syntax error, unexpected 'echo' (T_ECHO)

Any idea what could be causing this thanks .
Title: Re: Syntax Error on Member List
Post by: Kindred on August 23, 2021, 03:34:57 PM
If you want us to help, you really need to provide the entire error, including file names and line numbers
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 24, 2021, 02:17:37 PM
Quote from: Kindred on August 23, 2021, 03:34:57 PMIf you want us to help, you really need to provide the entire error, including file names and line numbers

Don't mean to be rude but I posted in another post about this is all I had for the error logs.

Quote from: Legosi on August 21, 2021, 03:20:24 PMThis is all I see on the error log. Nothing else. I wish I knew what was causing this.

Member List Error.JPG

And the same kind of thing again. I've been using SMF software since 2008, if I had the error and the line numbers I would post them. More to the point I'd fix it myself but I don't have them so that's why I came here helping someone could help.
Member List Error 2.JPG
Title: Re: Syntax Error on Member List
Post by: shadav on August 24, 2021, 02:27:51 PM
in your admin under configuration then under security and moderation
checkmark Include database query in the error log

in your admin under configuration then under server settings
checkmark Disable evaluation of templates

this mod is also helpful to install for narrowing down errors
https://custom.simplemachines.org/mods/index.php?mod=4249
Title: Re: Syntax Error on Member List
Post by: Arantor on August 24, 2021, 02:33:28 PM
Or you could do what I did, grab the fil, run php -l, see where the error is. The error in this case is the wrong number of brackets on the above posted code.

It should be:
if ($context['user']['is_admin'] && (!empty($member['post_percent'])))
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 24, 2021, 03:01:16 PM
Quote from: shadav on August 24, 2021, 02:27:51 PMin your admin under configuration then under security and moderation
checkmark Include database query in the error log

in your admin under configuration then under server settings
checkmark Disable evaluation of templates

this mod is also helpful to install for narrowing down errors
https://custom.simplemachines.org/mods/index.php?mod=4249

Thanks, I will have a look at that mod.



Quote from: Arantor on August 24, 2021, 02:33:28 PMOr you could do what I did, grab the fil, run php -l, see where the error is. The error in this case is the wrong number of brackets on the above posted code.

It should be:
if ($context['user']['is_admin'] && (!empty($member['post_percent'])))

Sorry I didn't know as I've not had them issues before. Just trying to figure this out.
Title: Re: Syntax Error on Member List
Post by: WolfJ on August 24, 2021, 03:06:12 PM
Quote from: Arantor on August 24, 2021, 02:33:28 PMOr you could do what I did, grab the fil, run php -l, see where the error is. The error in this case is the wrong number of brackets on the above posted code.

It should be:
if ($context['user']['is_admin'] && (!empty($member['post_percent'])))

This has fixed the member list page. Thank you very much.
Title: Re: Syntax Error on Member List
Post by: GL700Wing on August 24, 2021, 09:02:13 PM
Quote from: Arantor on August 24, 2021, 02:33:28 PMOr you could do what I did, grab the fil, run php -l, see where the error is. The error in this case is the wrong number of brackets on the above posted code.

It should be:
if ($context['user']['is_admin'] && (!empty($member['post_percent'])))
Just curious - the code I posted had two opening brackets and two closing brackets - why does the '!empty' test also need to be enclosed in brackets?
Title: Re: Syntax Error on Member List
Post by: Arantor on August 25, 2021, 01:39:29 PM
I'll be honest, I think what happened is what I think the OP did: I fixed the first missing bracket - and I didn't fix the other one. I didn't even see that you'd changed it, I'm sorry. I just assumed that since it was listed as not fixing it, I fixed the symptom that was pointed out, ran it through php -l to avoid guesswork about what was wrong, and noted a mismatch of brackets.

You don't need the third bracket, as long as the correct number of brackets is present.
Title: Re: Syntax Error on Member List
Post by: GL700Wing on August 25, 2021, 07:59:42 PM
Quote from: Arantor on August 25, 2021, 01:39:29 PMYou don't need the third bracket, as long as the correct number of brackets is present.
No problems - that's what I thought.

Seems whoever made the manual edits to the template file originally - perhaps the OP - didn't know enough about PHP coding to edit it correctly.