How do you know if you have gallstones or a gallblader infection?

Usually not infected. Most gallbladder problems are not truly infections, but rather blockage of the gallbladder opening by gallstones (called biliary colic or cholecystitis), exemplified by pain after eating and nausea. In the event the bile actually get infected, patients can become very sick, with elevation in bilirubin, fever, elevated white count (cholangitis). Diagnosis is made clinically and by ultrasound.
See a doctor. Gallstones may cause intermittent upper abdominal pressure discomfort & nausea that gets worse after eating & then resolves. Gallbladder infection is less common & usually related to gallstones & blockage of the gallbladder or bile duct. Usually would be associated with severe upper abdominal pain that does not go away, nausea & vomiting. Needs evaluation & proper testing with your doctor to tell.
See a physician. Clinical examination/history and imaging studies (i.E ultrasound, mri), can definitively make the diagnosis, so see a physician if you are having significant pain in the right upper quadrant of your abdomen.
Easiest. Way is a sonogram to diagnose some lab tests but are less specific ct scan can also show them.
Infection. Active infection causes fever and elevated white blood cell count. But if you have gall stones and pain, you probably some element of infection smoldering.