In its minimal or default form, \labels only store the counter and the page that it's on, the former retrievable via \ref and the latter retrievable via \pageref. TeX \label-\ref systems is used to mark the last referencable counter and store it in the \label. If there is no counter that was last referenced (as in your case), there will be no appropriate \ref, hence your ?? as output.
As a brief introduction to how one can use counter referencing, here is a way to achieve your result. First you define a counter using
\newcounter{mycount}
Then, whenever you want to store the counter for referencing, you perform
\refstepcounter{mycount}
This does two things: increases the counter by 1 (or "step" it), and adds a "referencing" capability or mark. Now, if you use \label it will store the value of mycount as well as the page that mycount was last \refstep-ped. Here's a minimal example of how that could work in your instance:

\documentclass{article}
\newcounter{mycount}
\newcommand\twolabels[2]
{
\refstepcounter{mycount}\label{my:#1}%
\refstepcounter{mycount}\label{my:#2}%
}
\begin{document}
\section{foo}
\twolabels{4}{a}
I have two labels: \ref{my:4} and \ref{my:a}.
\end{document}
Now, this doesn't mean that you always have to create your own counter if you want to refernece something via \label-\ref. Instead, there are other counters that is \refstep-ped like section whenever you perform \section. Using the example above, if you had just placed \label{test} after the \section and subsequently used \ref{test}, you retrieve the section number 1 in the text.
Finally, you can also modify the way the counter is displayed in the text. For example, if you're interested in (lower case) Roman numerals for your counter, you could add
\renewcommand{\themycount}{\roman{mycount}}
after defining the counter mycount.
You need to compile twice for the references to be accurate, since information is first stored in an .aux file and retrieved upon the second compile.