Well, since the code is automatically generated, it printed this:<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>Content-Encoding: base64<br>print<br>print content.encode('base64')<br>
<br>which threw this error:<br><br>[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler
mod_python.cgihandler: Traceback (most recent call last):
<br>[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98]
PythonHandler mod_python.cgihandler: File
"/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch\n result = object(req)
<br>[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98]
PythonHandler mod_python.cgihandler: File
"/usr/lib64/python2.4/site-packages/mod_python/cgihandler.py", line 96,
in handler\n imp.load_module(module_name, fd, path, desc)
<br>[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98]
PythonHandler mod_python.cgihandler: File
"/var/www/vhosts/<a href="http://13gems.com/httpdocs/stxresort/cart/getpic1.py">13gems.com/httpdocs/stxresort/cart/getpic1.py</a>", line
24
<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler mod_python.cgihandler:     Content-Encoding: base64
<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler mod_python.cgihandler:                     ^
<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler mod_python.cgihandler: SyntaxError: invalid syntax
<br><br>Ideas? TIA,<br>V<br><br><div class="gmail_quote">On Wed, Oct 7, 2009 at 12:00 PM, Rami Chowdhury <span dir="ltr"><<a href="mailto:rami.chowdhury@gmail.com">rami.chowdhury@gmail.com</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;">
<div class="im">On Wed, 07 Oct 2009 09:38:09 -0700, Victor Subervi <<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yes it is. I have had it print to screen already, and there is data in the<br>
database.<br>
V<br>
</blockquote>
<br></div>
If you're confident that the data is correct and hasn't been corrupted, then I'm afraid I'm out of ideas. Perhaps you could try transmitting it as base64, which might make it more robust in transmission and easier to decode and find errors locally? You'd just need to change the end of your script to read:<div class="im">
<br>
<br>
print '''Content-Type: image/jpeg<br></div>
Content-Encoding: base64<br>
<br>
'''<br>
print<br>
print content.encode('base64')<br>
<br>
HTH,<br><font color="#888888">
Rami</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
On Wed, Oct 7, 2009 at 10:03 AM, Rami Chowdhury <<a href="mailto:rami.chowdhury@gmail.com" target="_blank">rami.chowdhury@gmail.com</a>>wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, 07 Oct 2009 06:37:08 -0700, Victor Subervi <<br>
<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>> wrote:<br>
<br>
 I took out the line in question (with text/html). Now it prints to screen<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
the url. It did that before. Strange. Any other ideas?<br>
TIA,<br>
V<br>
<br>
</blockquote>
<br>
Looking at the output, it seems the reason for this (for me) is that<br>
Firefox can't find the image or any alt text for it, so it's just using the<br>
image URL. Are you certain the image data (i.e. the 'content' string) is<br>
correct, and being encoded correctly in the output?<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Oct 6, 2009 at 3:40 PM, Rami Chowdhury <<a href="mailto:rami.chowdhury@gmail.com" target="_blank">rami.chowdhury@gmail.com</a><br>
>wrote:<br>
<br>
 On Tue, 06 Oct 2009 13:26:19 -0700, Victor Subervi <<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>> wrote:<br>
<br>
 The code in question is generated automatically from another script. I<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
took<br>
your idea of the \r\n\r\n and added triple quoting and now it prints out<br>
this:<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>
print '''Content-Type: text/html<br>
<br>
'''<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>
<br>
To answer your questions, I have no idea what eNom has done to their<br>
servers, which is where the other site was hosted (never went live), but<br>
am<br>
in the process of building on DreamHost, who seems to be a FAR better<br>
service than eNom, whom I actually had to report to the BBB and they<br>
never<br>
fixed or acknowledged very obvious problems. At any rate, the above code<br>
gets the browser to print out all the binary "garbage" that should<br>
translate<br>
into an image (you can look:<br>
<a href="http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1" target="_blank">http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1</a> ). Any more ideas<br>
would<br>
be helpful.<br>
<br>
<br>
</blockquote>
Going to that URL, my browser now tries to render an HTML page, and I can<br>
now see the 'Content-Type: image/jpeg' string being printed into the HTML<br>
source. Have you tried removing the 'Content-Type: text/html' header,<br>
with<br>
the new triple-quoted syntax?<br>
<br>
<br>
--<br>
Rami Chowdhury<br>
"Never attribute to malice that which can be attributed to stupidity" --<br>
Hanlon's Razor<br>
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)<br>
<br>
<br>
</blockquote></blockquote>
<br>
<br>
--<br>
Rami Chowdhury<br>
"Never attribute to malice that which can be attributed to stupidity" --<br>
Hanlon's Razor<br>
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)<br>
<br>
</blockquote></blockquote>
<br>
<br>
<br></div></div>
-- <br><div><div></div><div class="h5">
Rami Chowdhury<br>
"Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor<br>
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)<br>
</div></div></blockquote></div><br>