\usepackage{caption} breaks references to tables

With

\begin{table}[htdp] 
\begin{center}
    \begin{tabular}{ | c | c |}
    \hline
    A & B  \\ \hline
    1 & 2 \\ 
    \hline
    \end{tabular}
    \caption{my cap}
\end{center}
  \label{table:example}
\end{table}

the label is defined when the center environment has already been closed and the object which the reference should be attached to has been forgotten.

Never use the center environment inside figure or table:

\begin{table}[htbp] 
\centering
    \begin{tabular}{ | c | c |}
    \hline
    A & B  \\ \hline
    1 & 2 \\ 
    \hline
    \end{tabular}
    \caption{my cap}\label{table:example}
\end{table}

Notice also that d is not among the possible float specifiers and probably you were meaning b (bottom).


Had kind of the same Error, but for me the solution was, putting the \label after the \caption command (which makes kind of sense...)