Can't get 2 variables to work globally - out of scope error and ThingSpeak error

Your second point:

On line 99, you initialise a variable float temp.

That line is inside the if statement's {} block, so the variable is local to that block.

This means that your debug code around line 164 can't access it.

If you move that line so it's the first thing in loop like this:

void loop () {
float temp;
...
etc

Then everything that's inside the loop function will be able to use it.

So both your problems were to do with 'variable scope'. You might want to Google that term and do a bit of reading around the subject.

Good luck!