In almost all languages (if not all), the quotes have to be the same. What is allowed in between does vary, so it is usually best to look things up yourself. For example, http://dev.mysql.com/doc/refman/5.7/en/string-literals.html or https://www.sqlite.org/lang_expr.html (although the latter seems to be incomplete; “ is also allowed).
The only reason why you should encounter both quotes like you showed is when Username=‘ is part of a string itself. For example:
$inject_str = "' or Username='";
inject_sql($db,$inject_str);
@bolofecal**: “\” is not a “bar” but a backslash; “|” is called a (vertical) bar (or pipe). Also, the backslash escape is not allowed everywhere, including this challenge. Instead, one can use a double single/double quote (e.g.: ‘a’‘b’ or “a”“b”).