[DB-SIG] warning problem
Watt III, Glenn
gwatt3@backbonesecurity.com
Fri, 16 Aug 2002 09:39:05 -0400
Ok heres my problem i am running a cgi in which i am updating a database
here it is
#!/usr/local/bin/python
import cgi
import sys
import MySQLdb
# firstname (contians in order title firstname lastname)
# lastname (indicates accepted paper)
# title (indicates unreadpaper newpaper)
# email (email)
# web (web)
# city (city, state or country)
# state (nothing)
# country (nothing)
# papertitle (papertitle)
# abstract (abstract)
# cot (full paper)
sys.stderr =3D sys.stdout
connection =3D
MySQLdb.Connect(host=3D"localhost",user=3D"site",passwd=3D"s1te411",db=3D=
"backbo
ne")
cursor =3D connection.cursor()
try:
query =3D cgi.FieldStorage()
except:
print"Please run via CGI... Thank you"
sys.exit(0)
if query.has_key("accept"):
header =3D "Content-type: text/html\n"
print header
print """
<html>
<head>
<title>Hamburgerstand.com</title>
</head>
<body>"""
else:
print "Well that was kind of useless you didn't even decide whether
or not to accept"
sys.exit(0)
if query['accept'].value =3D=3D "Yes":
update =3D 'update newpapers set firstname=3D"' + =
query["name"].value +
'"'
update =3D update + ", title=3D'accepted'"
if query.has_key("emial"):
update =3D update + ', email=3D"'+query["email"].value+'"'
if query.has_key("web"):
update =3D update + ', web=3D"'+query["web"].value+'"'
if query.has_key("location"):
update =3D update + ', city=3D"'+query["location"].value+'"'
if query.has_key("papertitle"):
update =3D update + ', =
papertitle=3D"'+query["papertitle"].value+'"'
if query.has_key("cot"):
update =3D update + ', cot=3D"'+query["cot"].value+'"'
if query.has_key("subject"):
x =3D int(query["subject"].value)
if query.has_key("topic"):
x =3D x + int(query["topic"].value)
if query.has_key("ltvalue"):
x =3D x + int(query["ltvalue"].value)
if query.has_key("tech"):
x =3D x + int(query["tech"].value)
if query.has_key("prof"):
x =3D x + int(query["prof"].value)
if query.has_key("pres"):
x =3D x + int(query["pres"].value)
if query.has_key("length"):
x =3D x + int(query["length"].value)
x =3D x * 100 / 28
average =3D str(x)
update =3D update + ', lastname=3D"'+ average +'"'
update =3D update + ' where =
firstname=3D"'+query["refname"].value+'";'
print update
cursor.execute(update)
sys.exit(0)
else:
delete =3D 'delete from newpapers where
firstname=3D"'+query["refname"].value+'";'
cursor.execute(delete)
sys.exit(0)
It doesnt have a problem if query['accept'].value is equal to no. the
im fairly new to using MySQLdb module so the problem is probobly really
obvious but here is the error i get the the first three lines are just
the values i used in this instance but any no matter the values i have
the problems. I tried running it in IDLE to find what it would do and i
got a similar error however changed =3D 1 instead of zero=20
update newpapers set firstname=3D"Mr. asdf asdf", title=3D'accepted',
web=3D"mam,germdfskln", city=3D",dgl/kh h'xdkb, Bahamas",
papertitle=3D"kfjtrjhmbu", cot=3D"erjgfjdlfg;sldfj asdfjasdkjfasdfemwrkj
asdmfkffkfkfkfkfk awerj75kjfvvyhmhfsdauer You can contact the author at:
mfkeigk", lastname=3D"100" where firstname=3D"Mr. asdf asdf"; Traceback
(most recent call last): File
"/var/www/backbone/admin/newdesign/papers/cgi/final.py", line 77, in ?
cursor.execute(update)
File "/usr/local/lib/python2.1/site-packages/MySQLdb/cursors.py", line
61, in execute r =3D self._query(query) File
"/usr/local/lib/python2.1/site-packages/MySQLdb/cursors.py", line 168,
in _query rowcount =3D self._BaseCursor__do_query(q) File
"/usr/local/lib/python2.1/site-packages/MySQLdb/cursors.py", line 118,
in __do_query self._check_for_warnings() File
"/usr/local/lib/python2.1/site-packages/MySQLdb/cursors.py", line 150,
in _check_for_warnings raise Warning, self._info
_mysql_exceptions.Warning: Rows matched: 1 Changed: 0 Warnings: 1=20
any help would be greatly appeciate thanks!