Okay, trying this again with everything working and no ValueError or any other errors, here we go:<br><br>Load this code. Unless you use a similar login() script, you will want to edit your own values into the user, passwd, db and host:<br>
<br>#!/usr/bin/python<br><br>import MySQLdb<br><br>import sys,os<br>sys.path.append(os.getcwd())<br>from login import login<br>user, passwd, db, host = login()<br><br>pic = "pic1"<br>w = 20<br>x = 0<br>d = 6<br>
y = 1<br><br>getpic = "getpic" + str(w) + ".py"<br>try:<br>  os.remove(getpic)<br>except:<br>  pass<br>code = """<br>#!/usr/local/bin/python<br>import cgitb; cgitb.enable()<br>import MySQLdb<br>
import cgi<br>import sys,os<br>sys.path.append(os.getcwd())<br>from login import login<br>user, passwd, db, host = login()<br>form = cgi.FieldStorage()<br>picid = int(form["id"].value)<br>x = int(form["x"].value)<br>
pics = {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\<br>9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'}<br>
pic = pics[x]<br>db = MySQLdb.connect(host, user, passwd, db)<br>cursor= db.cursor()<br>sql = "select %s from products where id='%s';" % (pic, str(picid))<br><br>cursor.execute(sql)<br>content = cursor.fetchall()[0][0].tostring()<br>
cursor.close()<br>print 'Content-Type: image/jpeg'<br>print<br>print content<br>"""<br>script = open(getpic, "w")<br>script.write(code)<br>script.close()<br><br><br><br>and then surf to:<br>
<a href="http://whatever.url/getpic20.py?id=6&x=1">http://whatever.url/getpic20.py?id=6&x=1</a><br><br><br>Also, please re-send the link on how to post good questions to the list. I cannot find it.<br>TIA,<br>Victor<br>