Gabriel, don't you remember fighting this through with me a year or two ago? It worked just fine back then, but now the same code doesn't work! Go figure! We've tweaked it to this point:<br><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:'pic2',3:'pic3',4:'pic4',5:'pic5',6:'pic6'}<br>pic = pics[x]<br>db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)<br>
cursor= db.cursor()<br>sql = "select " + pic + " from products where id='" + str(picid) + "';"<br>cursor.execute(sql)<br>content = cursor.fetchall()[0][0].tostring()<br>cursor.close()<br>
print '''Content-Type: image/jpeg<br><br>'''<br>print<br>print content<br><br>Your comments are very much appreciated.<br>TIA,<br>V<br><br><div class="gmail_quote">On Wed, Oct 7, 2009 at 9:51 AM, Gabriel Genellina <span dir="ltr"><<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">En Tue, 06 Oct 2009 17:26:19 -0300, Victor Subervi<br>
<<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>> escribió:<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The code in question is generated automatically from another script. I took<br>
your idea of the \r\n\r\n and added triple quoting and now it prints out<br>
this:<br>
</blockquote>
<br></div>
That's still wrong. The output should be:<br>
<br>
- a line containing Content-Type: image/jpeg<br>
- a blank line (no more!)<br>
- the actual image data<br>
<br>
A Content-Type of text/html is just *wrong* for an image...<br>
<br>
-- <br>
Gabriel Genellina<br><font color="#888888">
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>