I'm currently working through an algebra book, and during the chapter about rational expressions and inequalities, the author has a side note in which he states:


  Never divide both sides of the equation by a variable, even if you're
  doing it to try to solve a rational equation, because there's a very
  real danger that you will actually eliminate answers.


The reason I'm asking this question is because I didn't understand how answers can be eliminated when dividing both sides of an equation by a variable.

Can you show me an example of how this can happen and why?

When you divide, you are implicitly assuming that the number you are dividing by is not equal to zero. By dividing, you are excluding the possibility that the number in question is zero, and as such you may be eliminating correct answers.

For a very simple example, consider the case of the equation $x^2-x=0$.

There are two answers: $x=0$, and $x=1$. However, if you "divide by the variable", you can end up doing this:
$$\begin{align*}
x^2 - x & = 0\\
x^2 &= x &&\text{(adding }x\text{ to both sides)}\\
\frac{x^2}{x} &= \frac{x}{x} &&\text{(divide by }x\text{, which assumes }x\neq 0)\\
x &= 1.
\end{align*}$$
So you "lost" the solution $x=0$, because when you divided by $x$, you implicitly were saying "and $x\neq 0$". In order to "recover" this solution, you would have to consider "What happens if what I divided by is equal to $0$?"

For a more extreme example, consider something like
$$(x-1)(x-2)(x-3)(x-4)(x-5)(x-6)=0.$$
Since a product is equal to $0$ if and only if one of the factors is equal to $0$, there are six solutions to this equation: $x=1$, $x=2$, $x=3$, $x=4$, $x=5$, and $x=6$. Divide both sides by $x-1$, and you lose the solution $x=1$; divide both sides by $x-2$, you lose $x=2$. Continue this way until you are left with $x-6=0$, and you lost five of the six solutions. And if then you go ahead and divide by $x-6$, you get $1=0$, which has no solutions at all! 

Whenever you divide by something, you are asserting that something is not zero; but if setting it equal to $0$ gives a solution to the original equation, you will be excluding that solution from consideration, and so "eliminate" that answer from your final tally.
