My misunderstanding. Here's the new code:<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>'''<br>print<br>print content.encode('base64')<br>
<br>Unfortunately, the same result of printing the url.<br>V<br><br><br><div class="gmail_quote">On Wed, Oct 7, 2009 at 12:56 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><div></div><div class="h5">On Wed, 07 Oct 2009 10:50:00 -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;">
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<br>
mod_python.cgihandler: Traceback (most recent call last):<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler<br>
mod_python.cgihandler: File<br>
"/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in<br>
HandlerDispatch\n result = object(req)<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler<br>
mod_python.cgihandler: File<br>
"/usr/lib64/python2.4/site-packages/mod_python/cgihandler.py", line 96, in<br>
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<br>
mod_python.cgihandler: File "/var/www/vhosts/<br>
<a href="http://13gems.com/httpdocs/stxresort/cart/getpic1.py" target="_blank">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<br>
mod_python.cgihandler: Content-Encoding: base64<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler<br>
mod_python.cgihandler: ^<br>
[Wed Oct 07 10:47:42 2009] [error] [client 66.248.168.98] PythonHandler<br>
mod_python.cgihandler: SyntaxError: invalid syntax<br>
<br>
Ideas? TIA,<br>
V<br>
<br>
</blockquote>
<br></div></div>
I'm sorry, I don't understand how the code is being auto-generated? Is there no way to place the 'Content-Encoding' header inside the triple-quoted string, where it should go?<br><font color="#888888">
<br>
-- <br></font><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>