If you don't have a shallot on hand when cooking, there are several other ingredients you can use as a replacement. Depending on the dish you're making, any of the following might work well: onion, garlic, leek, chive, or scallion.
For example, if a recipe calls for minced shallots and you don't have any, you could mince up a small onion or two cloves of garlic instead. If a recipe calls for slicing a shallot, any of the other options could be sliced thin in its place. In general, using another allium in place of a shallot will work well in most cases.
There are some dishes where another ingredient might work better than an allium though. For instance, if a recipe calls for pickled shallots and you don't have any on hand (or just don't want to make them), diced cucumber or roasted red pepper would both be tasty substitutes.