473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: Prob. w/ Script Posting Last Value

En Thu, 17 Apr 2008 15:51:43 -0300, Victor Subervi <vi***********@gmail.comescribió:
On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden <st***@holdenweb.comwrote:
> Victor Subervi wrote:
Gabriel provided a lovely script for showing images which I am modifying
for my needs. I have the following line:
print '<img src="getpic.py?id=%d&x=%d"><br /><br /></td>\n' % (d, y)
where the correct values are entered for the variables, and those values
increment (already tested). Here is the slightly modified script it calls:
#!/usr/local/bin/python
import cgitb; cgitb.enable()
import MySQLdb
import cgi
form = cgi.FieldStorage()
picid = int(form["id"].value)
x = int(form["x"].value)
pic = str(x)
print 'Content-Type: text/html'
db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)
cursor= db.cursor()
sql = "select " + pic + " from products where id='" + str(picid) + "';"
cursor.execute(sql)
content = cursor.fetchall()[0][0].tostring()
cursor.close()
print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content)
print content
I need to make it so that it will show all my images, not just the last
one. Suggestions, please.
That 'Content-Type: text/html' is wrong, you're returning an image here.
Are you sure that *different* pictures are stored in the database? Perhaps there was an error and all columns have the same picture.
Also make sure you're not seeing a cached image in your browser.

In your "page generator" page, replace

print '<img src="getpic.py?id=%d&x=%d"><br /><br /></td>\n' % (d, y)

by

for d, y in (results of some DB query to get d and y for each image):
print '<img src="getpic.py?id=%d&x=%d"><br /><br /></td>\n' % (d, y)

Well, I just tried this:

#! /usr/bin/python
print """Content-type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<input type='hidden' name='db' value='benobeno_bre' />
"""
y = 1
for d in 2, 12:
while y < 12:
print '<img src="getpic.py?id=%d&x=%d"><br /><br /></td>\n' % (d, y)
y += 1
print"""
</body>
</html>"""
and it printed the same image over and over again :(
An empty line is missing after Content-Type and before the actual content.
Look at the source and be sure the src= attribute is generated correctly.

--
Gabriel Genellina

Jun 27 '08 #1
0 694

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred | last post by:
This script was left to me to get fixed, but since i cannot vb, i stuck. Anyone know what i have to do to make it work? <package> <job id="vbs"> <script language="VBScript"> Set WshNetwork =...
2
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title...
5
by: Steve | last post by:
Hi, I have a private website for 20 people that is similar to a web email client like hotmail. There are two frames, one on the left with links for "New", "History", "Todays" and a frame on the...
6
by: oeyvind toft | last post by:
I have a frameset consisting of 3 frames: top, left and right. In top frame: body onload calls a js init function to set (or resets) values in textareas etc...in all frames. In right frame: A...
5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
2
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
1
by: mahajanrahuld | last post by:
hi i written the script for database connectivity with ms access , connection is proper but the script can not display any reslut on browser ..... code is ..... #!usr/bin/perl use...
0
by: Steve Holden | last post by:
Victor Subervi wrote: In your "page generator" page, replace print '<img src="getpic.py?id=%d&x=%d"><br /><br /></td>\n' % (d, y) by for d, y in (results of some DB query to get d and y for...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.