Join the Facebook Fan Page.

Main Menu

Syntax error, unexpected ')'

Started by Rupurudu!, February 10, 2024, 10:34:01 PM

Previous topic - Next topic



I am getting this error in the Administration Center:

Usually, there are filename and line markers with these errors, so I can check and fix. But there are no file or line markers on the error. I don't know how am I supposed to find the extra paranthesis?

Sir Osis of Liver

Did you change anything recently?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters


It's been like this for a while now, since it only effects a part of the admin CP, I sort of ignored it. But it's annoying and would like to fix it if possible.

If only I could learn which file or lane it is, or anything that I can search the files for. It's nearly impossible to find an extra ) in all of those files.


Well, what,  specifically, are you attempting to do in the admin center when you get the error?

Because the admin functions are not in one single file

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Here are the list of pages not working:

--> Core Features
--> Features and Options
--> Security and Moderation
--> Modification Settings
--> Search Engine Optimization (Optimus plugin)

All other pages work.

Aleksi "Lex" Kilpinen

You might be able to find further details in the error logs, either SMF or Server, but simply based on that I'd be looking at any mods that add their own controls there, starting with the Optimus mod. Perhaps something went wrong when installing them.

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF


Unfortunately, the error log gives out no more detais.  :(
You cannot view this attachment.

I'll try copying the forum to localhost, and enabling show_errors from php.ini. With a bit of luck, it might show me the file/lane number.


ManageSettings.php is the likely culprit. A bad mod maybe.

Also, did you remove the index.php from the URL and if so how? Bad things can happen depending on how.

Dave J

I would tend to think it might be some code that wasn't removed when a mod was uninstalled.

I have in the past removed all the mods installed and then uploaded a clean version of the Sources folder and then reinstall the mods 1 by 1 and check if the error exists following that.

Backup everything first ;)
If you want quizzes to add to the new SMF2.1 quiz mod go here . There are also walkthroughs in the forum to explain how to install them and other tips.


Quote from: Arantor on February 12, 2024, 06:33:04 AMManageSettings.php is the likely culprit. A bad mod maybe.

Also, did you remove the index.php from the URL and if so how? Bad things can happen depending on how.
Yeah, the problem is in the ManageSettings.php.

I downloaded the SMF2.0 from the Simple Machines and compared the ManageSettings.php from my installation.
At line 1503, there is a curly bracket, where in my installation there is a regular bracket.
Without the compare tool showing the line difference, it would be impossible for me to find it.

I can finally access the Admin Center again, thanks a lot!

For the URL:

    // Makes it easier to refer to things this way.
    $scripturl = $boardurl . '/index.php';
    // Makes it easier to refer to things this way.
    $scripturl = $boardurl . '/';

Unlike the "Search engine friendly URLs" option This will work regardless of the HTTP server you have, if you set index.php as the default index page.


Yeah you *really* shouldn't do that. It doesn't help SEO but it will break things for people on their first visit to the site.


Yeah, this happens because SMF is configured to add '?PHPSESSID=' to the url.

    // Attempt to change a few PHP settings.
    @ini_set('session.use_cookies', true);
    @ini_set('session.use_only_cookies', false);
    @ini_set('url_rewriter.tags', '');
    @ini_set('session.use_trans_sid', false);
    // Attempt to change a few PHP settings.
    @ini_set('session.use_cookies', true);
    @ini_set('session.use_only_cookies', true);
    @ini_set('url_rewriter.tags', '');
    @ini_set('session.use_trans_sid', false);

Make sure that 'session.use_trans_sid' is false and 'session.use_only_cookies' is true.

I would also point out that, adding '?PHPSESSID=' to the url is not just a thing makes your URL 'long', it is a a security exploit that is disabled in the default PHP configuration.

See PHP documentation here [nofollow]

Edit: I would like to point out that, SMF uses it's own cookies for Authentication and does not rely on PHP Session. So, you can't get hacked if you shared a url with your own '?PHPSESSID='.


Does that actually turn it off? Because the SID injector is custom SMF code which is used to be able to differentiate the number of bot users that don't otherwise provide cookies. (And this is potentially important for the purposes of not causing major contention issues on the online and flood control tables)

It's not PHP doing the injection.

Edit: I've been campaigning for this feature to be removed for years, however *this isn't the way to do it*. The correct way is to surgically alter QueryString.php and fix some of the side issues this will produce.


Yeah you are right. This isn't PHP's doing. I didn't noticed the ob_sessrewrite function until now. ::)

What does this function even do?

It checks for 'empty($_COOKIE)', so the user's browser does not support cookies,
It checks for 'empty($context['browser']['possibly_robot'])' so this does not run on bots.

I think this function makes a fallback for users that does not support cookies? :o What kind of user disables all cookies and expects the forum software work? :X

Also why didn't they used PHP's own URL Rewriter? Because PHP only rewrites URLs in 'a=href,area=href,frame=src,input=src,form=' tags. This function rewrites everything.

Btw, using 'session.use_only_cookies true' does in fact disable the rewrite. Honestly, I don't know why...


The function dates back 20 years back to when search engines didn't use cookies at all and, as I said, it was there to track bot sessions to avoid hammering the online and flood control logs. (And possibly the sessions table, which was a definite problem years ago on Debian based servers)

I haven't looked into the mechanics of how/why the rewriter works (it's been many years since I was dev team here), just that it has long been the case that removing index.php from the URL screws up the rewriter such that it breaks theme paths by injecting them with the session inappropriately.

If you have disabled the rewriter you can remove index.php from the URL, because it will just be unnecessary as opposed to unnecessary and harmful.