[Tex/LaTex] ! Undefined control sequence

errors

I am getting an ! Undefined control sequence error when compiling the following code:

\documentclass[11pt,table,a5paper]{article}
\usepackage{array,ragged2e}
\usepackage{graphicx}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usepackage[top=2cm, bottom=2cm, outer=1cm, inner=2.1cm,twoside, headsep=26pt]{geometry}
\usepackage{ifthen}
\usepackage{wrapfig}
\usepackage{comment}
\usepackage{parskip}
\usepackage{framed} 
\usepackage{sidecap}
\usepackage{longtable}
\begin{document}
\begin{longtable}{|p{2.7cm}|p{1.0cm}|p{2.4cm}|p{1.0cm}|p{1.3cm}|p{0.8cm}|} 
\hline 
\rowcolor{white} \textbf{ \textcolor{white}{A}} &\textbf{ \textcolor{white}{B}} &\textbf{ \textcolor{white}{C}}  &\textbf{ \textcolor{white}{D}} &\textbf{    \textcolor{white}{E}} &\textbf{ \textcolor{white}{P}} \\ 
\endfirsthead
\rowcolor{white} \textbf{ \textcolor{white}{A}} &\textbf{ \textcolor{white}{B}} &\textbf{ \textcolor{white}{C}}  &\textbf{ \textcolor{white}{D}} &\textbf{    \textcolor{white}{E}} &\textbf{ \textcolor{white}{P}} \\  
\endhead 
\hline 
\newcommand{\dsr}{\rule[-3.5cm]{0pt}{4cm}} 
\dsr  XXXXXXX  & \dsr  3.38&  \multirow{1}{*}{\parbox{2.5cm}  {\textcolor{black}{XXXXXXX >2,~\\ 
~\\ 
XXXXXXX~\\ 
~\\ 
XXXXXy XXXXX XXXXX XXXXX}}} 
&\dsr 2.36\% & \dsr 0.62\% & \dsr 18 \\\cline{1-2} \cline{4-6} 
\hline 
\end{longtable}} 
\end{document}

How to fix this issue?

Best Answer

Moving the definition of \dsr command to before \begin{longtable} and adding \usepackage{multirow} in the preamble seem to solve the problem.

A definition inside a cell is only defined in the cell (which forms a group) unless it is made global. (Thanks to Qrrbrbirlbel for mentioning this in the comment.)

Output looks like this:

enter image description here