Синтаксическая ошибка рядом с ")" @ строка 1
#! /usr/bin/env python3 print('Content-type: text/html\n') import MySQLdb, cgi def results_table(records): html = """ <!doctype html> <html> <head><meta charset="utf-8"> <link rel="stylesheet" href="http://cgi.soic.indiana.edu/~dpierz/i211.css"> <title>Employee Add</title></head> <body> <h1>New Employee Added!</h1> <table border='1' width='100%'> <tr><th>Employee_ID</th><th>Email</th><th>FirstName</th><th>LastName</th><th>Phone</th><th>Admin</th><th>Active</th></tr> {content} </table> <p><a href="EmployeeAdd.html">Go Back</a></p> </body> </html>""" table = "" for row in records: table += "<tr>" for item in row: table += "<td align='center'>"+str(item)+"</td>" table += "</tr>" print(html.format(content = table)) form = cgi.FieldStorage() email = form.getfirst("email", "") first_name = form.getfirst("first_name", "") last_name = form.getfirst("last_name", "") phone = form.getfirst("phone", "") admin = form.getfirst("admin", "") active = form.getfirst("active", "") try: #Always surround .execute with a try! SQL = "INSERT INTO Employee (Email, First_name, Last_name, Phone, Admin, Active)" SQL += "VALUES('" + email + "','" + first_name + "','" + last_name + "','" + phone + "','" + admin + "','" + active + "',);" cursor.execute(SQL) db_con.commit() SQL = "SELECT * FROM Employee; " cursor.execute(SQL) results = cursor.fetchall() except Exception as e: #Here we handle the error print('<p>Something went wrong with the SQL!</p>') print(SQL) print("\nError:", e) else: #This runs if there was no error results_table(results)
Что я уже пробовал:
Нигде в коде не удается найти синтаксическую ошибку
0x01AA
В конце высказывания слишком много запятых.
Этот ...."','" + active + "',);"
должно быть ...."','" + active + "');"