<div>Hi again:</div>
<div>Here is my code, an edit of Gabrielīs:</div>
<div> </div>
<div>#!/usr/local/bin/python<br>import cgitb; cgitb.enable()<br>import MySQLdb<br>def test():<br>  host = 'host'<br>  db = 'db'<br>  user = 'user'<br>  passwd = 'pass'<br>  db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)<br>
  cursor= db.cursor()<br>  cursor.execute('select pic1 from products where id="2";')<br>  content = cursor.fetchall()[0][0].tostring()<br>  f = open("somefile.jpg", "w")<br>  f.write(content)<br>
  f.close()<br>  print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content)<br>  print '<html><body>\n'<br>  print content<br>  print '</body><html>\n'<br>  cursor.close()<br>
 <br>test()<br></div>
<div>Now, when I surf to the url of this script, it prints out garbage that is a literal of the image, but not the image itself. However, if I surf to Ļsomefile.jpgĻ, I see the image!! Am I losing my mind?? Whatīs wrong here?</div>

<div>TIA,</div>
<div>Victor</div>