A runtime error happens while the program is being executed, whereas a syntax error results from flaws in the syntax of the code.