Fallacy of affirming the conclusion question [duplicate]

I'm a little unsure about the exact reason why/when you get "fallacy of affirming the conclusion"

In this simple example:

$$p\rightarrow q$$ $$q$$ $$----$$ $$\therefore p$$

Not exactly sure how I would format that but anyways, for the argument to be valid if $p \rightarrow q$ and $q$ are both true then $p$ must also be true. Is it an invalid statement because if $p$ is false and $q$ is true then $p \rightarrow q$ is true therefore, the fact that $p$ can be either false or true instead of it needing to be true makes it invalid?

Also, could someone explain to me why

$$p \rightarrow (q \rightarrow r)$$ $$q \rightarrow (p \rightarrow r)$$ $$-------$$ $$\therefore (p \vee q) \rightarrow r$$

is an invalid statement?

• So then all instances must conform to the conclusion? Commented Feb 14, 2015 at 7:15

The argument $p \rightarrow q, q \vdash p$ is a fallacy because if $p$ is false and $q$ is true then both $p \rightarrow q, q$ are true but the conclusion $p$ is false.
For the second argument, if $p$ is false, $q$ is true and $r$ is false we see that $p \rightarrow (q \rightarrow r)$ is true and $q \rightarrow (p \rightarrow r)$ is true but the conclusion $(p \lor q) \rightarrow r$ is false. Hence this argument is also a fallacy.
(However, the argument $p \rightarrow (q \rightarrow r), q \rightarrow (p \rightarrow r) \vdash (p \land q) \rightarrow r$ is valid.)