Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
Number of replies: 9
I updated my Moodle site from 4.1 to 4.2 and I got this error Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE) now I cannot enter my site what can I do? Please somebody can help me. I need the site for my students
Average of ratings: -
In reply to Juan Pablo Prado Otero

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Ken Task -
Picture of Particularly helpful Moodlers
Prior to the upgrade, did you:
1. make a full site backup consisting of code directory, DB dump, and minimally moodledata/filedir/
2. Check server environment to see if your server met requirements to run 4.2?
 
The error indicates your current PHP isn't at least 8.0 - now required to run a 4.2.   So, if you have a panel of some sort that can set the PHP version for your site, use that and set it to at least version 8.0 of PHP.

'SoS', Ken

In reply to Ken Task

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
Thank you Ken
I asked to my hosting enterprise and they say with shared hosting I can not have pop 8 0. Iam novice in this I don't know what to do
In reply to Juan Pablo Prado Otero

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
I asked to my host provider for updating the php version but I could not update to 4 2 yet I have the issue yet
Attachment Screenshot_20230429-140052_Chrome.jpg
In reply to Juan Pablo Prado Otero

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Ken Task -
Picture of Particularly helpful Moodlers
2 options

1. stay as you are but you have to restore the site backup (archive of the code and sql dump of the db for the moodle) you made just prior to the attempt at upgrading.   IF you followed directions to upgrade, you might have a moodle.old which is the old code.   Then all you need to do is erase the new code and move the contents of moodle.old into it's former location.
This assumes the DB has not be touched.

2. have hosting provider move your account to a system/VPS where you as the server admin can opt to use php 8.0.  But that means you take on more server admin.

4.1 of moodle is a long term support version.  So, in your case, there is no compelling reason to upgrade to 4.2 - even though in the future you will have to when support runs out.

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
Thank you so much Ken,
I will try to do the mentioned option 1
Than kyou so much
In reply to Ken Task

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
Hi Ken, 
I am confused about Cpanel and php versions.
1. at the C Panel in PHP MY ADMIN I see the following version

Web server

  • cpsrvd 11.102.0.32
  • Database client version: libmysql - mysqlnd 7.4.33
  • PHP extension: mysqli cur mbstring
  • PHP version: 7.4.33
2. but at 

MultiPHP Manager
I can change to PHP versions 8.0, 8.1, and 8.2 like this


3. if I change the PHP version to 7.4 I got the message:

The error I got this error Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

but If I change the PHP version to a different one like 8.0,8.1 or 8.2 I get this error


It seems the solution about updating to PHP 8.0 doesn't work in my case. Finally, I chatted with my provider and asked them about the update in 

Web server to 8.0 PHP version they said it will be ready but the version is stilled in 7.4

I am a novice in C PANEL, PHP, and coding.

Please, if somebody can help me to solve this issue I really appreciate it and if I have to pay some money I will do it because my sie is a project and research that I am developing right now.

Thanks a lot


In reply to Juan Pablo Prado Otero

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Ken Task -
Picture of Particularly helpful Moodlers
Well, you choose option 1 - put the old code back right?
Did you do that correctly? - all files/folders from moodle.old back to the location where that resided before?

When one makes a change like that to php, web services need to be restarted.
Did you restart apache?

Your screen shot shows that domain set to 8.1.   (all domains cept one).
Am not tech support for your provider.   So if this statement:

Web server to 8.0 PHP version they said it will be ready but the version is stilled in 7.4

then looks like you have to talk to your provider some more!  Was 8.0 available as a version in the drop downs?

'SoS', Ken


In reply to Ken Task

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
Hi Ken,
I appreciate all your help in my case, 
About the questions
Was 8.0 available as a version in the drop-downs?   Yes it is available
Did you restart Apache? No sr. I didn't know how to do it
put the old code back right? Not yet, because I have to study how to do it first, and cause I had the hopeless to update the site to 4.2, not because of the version but all the material I have created in Moodle.
I am learning how to understand this big world called Moodle.
I am going to do what you suggest to me.
Thanks a lot again
In reply to Juan Pablo Prado Otero

Re: Errro: Exception - syntax error, unexpected '|', expecting variable (T_VARIABLE)

by Juan Pablo Prado Otero -
At the end,
In my case the provider just gave me access to MySQL Version 5.7.23-23 and Moodle 4.2 needs MySQL Version 8.0 for that reason in my case I just can install Moodle til 4.1
If someone is having the  similar situation please check the  server for  MySQL Version.
My hosting provider doesnt give  MySQL Version 80 for sharing hostings. bad........