Der Versuch, eine Webanwendung (mit mySQL und Python) mit einer Liste von Wanderwegen in MA zu erstellen. Ich möchte nur auf einer Seite alle Namen von Routen in meiner DB angezeigt und kann nicht herausfinden, warum nichts angezeigt wird:<type 'exceptions.NameError'>
################################################################################
def getAllHikes():
"""
This is a middleware function to read from the database.
It returns a list containing records of all trails we have in the table.
"""
# connect to db
conn, cursor = getConnectionAndCursor()
# prepare SQL
sql = """
SELECT name
FROM hiking
"""
# run the SQL
cursor.execute(sql)
# fetch the results
data = cursor.fetchall()
# clean up
cursor.close()
conn.close()
return data
################################################################################
def showAllHikes(data):
'''Produce a table showing all trails, one per row.'''
print('''
Here are all the popular trails we have on file:
<table>
<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>
''') % (name, town)
print('''
</table>
''')
################################################################################
if __name__ == "__main__":
# get form field data
form = cgi.FieldStorage()
doHTMLHead("MassHike: A database of popular Massachusetts trails")
data = getAllHikes()
showAllHikes(data)
doHTMLTail()
ich dieses Problem immer auftreten, wenn ich versuche, mit Web-Anwendungen zu arbeiten. Ich bekomme eine Fehlermeldung args = ("globaler Name 'Name' ist nicht definiert")
Wenn Sie in sehr einfachen Worten zu erklären, würde ich es zu schätzen wissen. Ich verstehe das überhaupt nicht. Vielen Dank!
In welcher Zeile ist Ihr Fehler enthalten? Ist es das Ergebnis Ihrer SQL-Abfrage? – mprat