PHP fixes
Settings, errors, types and functions, with the version each answer was run on.

nginx 502 Bad Gateway with PHP-FPM: read the error log line first
A 502 means nginx got no usable answer from PHP-FPM. One line in the nginx error log says why: no socket, no permission, a dead worker or a big header.
Where is php.ini? Finding the file PHP actually loads
Run php --ini for the command line, and call php_ini_loaded_file() through the browser for the website. They are often two different files, and both count.
PHP error reporting and the PHP error log: where the errors go
PHP decides three things about an error: whether to report it, whether to show it, and where to log it. Print those settings first, then read the file.
MySQL server has gone away (2006) and lost connection (2013): the causes
MySQL error 2006 means the connection was closed before your query arrived: check idle timeout, packet size and server restarts, in that order, then reconnect.
MySQL error 1064: how to read the message and find the broken part
MySQL error 1064 quotes the statement from the first token the parser could not accept, so look at that word and the one just before it for the cause.
The uploaded file exceeds the upload_max_filesize directive in php.ini: fix
Set upload_max_filesize, a larger post_max_size and the web server's body limit, then restart PHP-FPM. The full chain, with a script that shows what applies.
PHPSolvedThe fix first, then the reason