I upgraded my server to PHP 8.1.22 in order to start a new Craft 4 site, and one (but not all) of my existing Craft 3 (3.6.17) sites is giving me the following error. How do I resolve this error? See error screenshot below:
Craft version 3.6.17 was released in June 2021, while PHP 8.1 had its first stable release in November 2021. The latest PHP version Craft could support at that point was 8.0, so you're running this version of Craft on an unsupported PHP version. That's why your getting errors.
To fix this issue and prepare for the Craft 4 update, first update to the last stable 3.x version, as mentioned in the update guide. This one will support newer PHP versions.
If you can't use the Craft binary (
php craft update all) because it's giving you errors as well, you can use Composer to update the library instead. Then run
php craft up to execute any required migrations. However, the better approach is to do the update first, and then bump your PHP version.