monica23 0 Newbie Poster

Good day everyone, i need to display image from the database but the code returns error page when i tried to print image from the database using

print fout

below is the entire codes

#! /data/python
import MySQLdb
import sys


print ("Content-type: image/jpeg");
print # End of headers!

try:
    cx = (*********)

    cursor = cx.cursor()

    cursor.execute("SELECT photo FROM picture LIMIT 1")

    fout=cursor.fetchone()[0]
    print fout

    #fout.close()

    #cursor.close()
    cx.close()

except IOError, e:
    print "Error %d: %s" % (e.args[0],e.args[1])
    sys.exit(1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.