I have deleteuser.py where i need to delete one user, here is the code:
# Import modules for CGI handling
import MySQLdb
import cgi, cgitb
# Open database connection
db = MySQLdb.connect("localhost", "root", "", "moviedb" )
# prepare a cursor object using cursor() method
cursor = db.cursor()
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
iduser = form.getvalue('iddelete')
# execute SQL query using execute() method.
try:
cursor.execute("""DELETE FROM user WHERE
ID = '%s'""",(iduser))
# Commit your changes in the database
db.commit()
except:
db.rollback()
# disconnect from server
db.close()
print "Content-Type: text/plain;charset=utf-8"
print
I have no error but it doesn`t work. The database is still the same.
Thank you
exceptblock. Remove that so you can see what is actually going wrong. Never, ever, blindly catch and swallow exceptions.