LaTeX Warning: Citation <name> undefined and bibliography using bibtex not showing

I was just setting up bibliography for my document using LaTeX. However I had forgotten how to do so and got all kinds of errors trying to set this up. But eventually I got it working. My problem was that I was using LaTeX standard bibliography formatting together with Bibtex. I will show you what went wrong.

The solution

The problem in short was that I was using the inline format in my Bibtex database file, which looked something like the following (examples taken from overleaf):

Albert Einstein. 
\textit{Zur Elektrodynamik bewegter K{\"o}rper}. (German) 
[\textit{On the electrodynamics of moving bodies}]. 
Annalen der Physik, 322(10):891–921, 1905.

However the file contents should have looked like the following:

    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
        [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    year =         "1905"

This was the reason why I got the LaTeX Warning: Citation <name> undefined error. Which was the reason why the references section was empty.

Another error that I had, was that I had messed up the following lines:


\bibliography{bib} was pointing to a file that was actually named bib. This has the extension .bib making it the full filename bib.bib. However you should only write bib in the bibliography tag. The file can be seen in the following image named "bib":


I hope this helps someone out there, let me know in the comments if it did!