[Tutor] Help: CGI Error in a Python Application

ajay singh ajay_4may at yahoo.co.in
Wed May 5 04:45:10 EDT 2004


I have wriiten a Python Script, which runs through a
Webserver. The script generates a form, where the user
feeds data and submits the form. The values submitted
by the user, populates a MySql database.

The problem is:

After submitting the values, the database gets
updated, but an error is generated which is quoted
below, as seen in the browser:


------------------------------------------------
CGI Error
The specified CGI application misbehaved by not
returning a complete set of HTTP headers. The headers
it did return are:
-----------------------------------------------


The Python code is as below:

--------------------------------------------

#!c:\python23\python
import cgi
import sys,os
import string
import MySQLdb
db=MySQLdb.connect(host="localhost",user="root",passwd="",db="power")
cursor=db.cursor()
print "<html>"
print "<head>"
print "</head>"
print "<body>"
s=os.environ['QUERY_STRING']
q=cgi.parse_qs(s)
sname=q['txtname'].pop()
scapacity=q['capacity'].pop()
sstate=q['txtstate'].pop()
sregion=q['region'].pop()
sfre1=q['frequency1'].pop()
sfre2=q['frequency2'].pop()
sfre3=q['frequency3'].pop()
sfre4=q['frequency4'].pop()
cursor.execute("insert into
station(name,region,capacity,state,fre1,fre2,fre3,fre4)
values(%s,%s,%s,%s,%s,%s,%s,%s)",
(sname,sregion,scapacity,sstate,sfre1,sfre2,sfre3,sfre4))

print "</body>"
print "</html>"

-------------------------------------------------


Can any one help me on this??

Ajay Singh


________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/



More information about the Tutor mailing list