Click here to Skip to main content
14,635,132 members

Syntax error near ")" @ line 1

Member 14870365 asked:

Open original thread
#! /usr/bin/env python3
print('Content-type: text/html\n')

import MySQLdb, cgi

def results_table(records):
    html = """ <!doctype html>
    <head><meta charset="utf-8">
    <link rel="stylesheet" href="">
    <title>Employee Add</title></head>
            <h1>New Employee Added!</h1>
            <table border='1' width='100%'>
            <p><a href="EmployeeAdd.html">Go Back</a></p>

    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 + "',);"

        SQL = "SELECT * FROM Employee; "
        results = cursor.fetchall()
except Exception as e:		#Here we handle the error
        print('<p>Something went wrong with the SQL!</p>')
        print("\nError:", e)
else:				#This runs if there was no error

What I have tried:

Can't find syntax error anywhere in code
Tags: database, syntax, MariaDB


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100