Re: [ilugd] Help: CGI Error in a Python Application
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >>> On Wednesday 05 May 2004 2:15 pm, as said: as> I have wriiten a Python Script, which runs through a as> Webserver. The script generates a form, where the user as> feeds data and submits the form. The values submitted as> by the user, populates a MySql database. as> as> The problem is: as> as> After submitting the values, the database gets as> updated, but an error is generated which is quoted as> below, as seen in the browser: as> as> as> as> CGI Error as> The specified CGI application misbehaved by not as> returning a complete set of HTTP headers. The headers as> it did return are: as> --- as> as> as> The Python code is as below: as> as> as> as> #!c:\python23\python as> import cgi as> import sys,os as> import string as> import MySQLdb as> db=MySQLdb.connect(host="localhost",user="root",passwd="",db="power") as> cursor=db.cursor() as> print "" as> print "" [snip] as> as> print "" as> print "" as> because of missing "Content-Type: text/html\n\n" before also, where are cursor.close() and db.close() Bhaskar - -- -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (GNU/Linux) Comment: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x01D5671C iD8DBQFAmL/BN1/UFgHVZxwRArpVAJ9UB4iAYmNnUmBhzbV7sI7iCdgThACeNona gkuTV/e3a4iEmHHKbPSnd24= =mdGT -END PGP SIGNATURE- ___ ilugd mailinglist -- [EMAIL PROTECTED] http://frodo.hserus.net/mailman/listinfo/ilugd Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/[EMAIL PROTECTED]/
Re: [ilugd] Help: CGI Error in a Python Application
Hi Ajay, You have missed HTTP header line in your python script. On Wednesday 05 May 2004 14:15, ajay singh wrote: > > 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 add here this line as print "Content-Type: text/html\n\n" > db=MySQLdb.connect(host="localhost",user="root",passwd="",db="power") > cursor=db.cursor() > print "" > print "" > print "" > print "" > 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 "" > print "" HTH Abhiram ___ ilugd mailinglist -- [EMAIL PROTECTED] http://frodo.hserus.net/mailman/listinfo/ilugd Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/[EMAIL PROTECTED]/