a needs to be defined first before your for loop. Don't remember off the top of my head if the rows in fetchall are strings, so you might have a problem there, too, so:
rows = cur.fetchall()
a = ""
for row in rows:
a=a+row+'<br>'
You could also remove the for loop and do this instead:
tag = '<br>'
a = tag.join(rows) + tag
Again, if the elements of "rows" is not usable as a string, you'll have to extract the data you want from each row element.
Your create_connection() function is a little odd, too. It doesn't actually return a connection. It either returns the results of your select or the exception it catches. There is no path to "return conn" as written. Additionally, Error is not defined in python. You probably mean "Exception", but instead of swallowing the exception and using it as a return value, it's likely best to let the exception get handled in the caller logic.
I tested NONE of this, so please excuse any errors which are likely typos.