Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging problem 1

Status
Not open for further replies.

Shem1985

Programmer
Nov 16, 2005
3
0
0
GB
I am trying to show 20 records per HTML page; I am getting the following error:

sql undefined, limit = '0,20'
TypeError: float argument required
args = ('float argument required',)

The code that I have written is:

pagesize=20

form=cgi.FieldStorage(keep_blank_values=True);
show=int(form.getfirst("show","0"));
limit='%s,%s'%(show,pagesize)

sql='''select vid_ID,
Description,from
q.vid %s order by vid_id desc limit %s'''% (limit)
db.execute(sql); v=db.fetchall();

 
Code:
sql='''select vid_ID,
Description,from
q.vid %s order by vid_id desc limit %s'''% (limit)
Two problems:
You have two %s and only one argument
You should either be using either just "limit" or "( limit, )", but not "(limit)
 
Hi, i am a complete beginner at this, and have tried a few things after i.e. taken out the %s after q.vid.

This still gives me a float argument required.

If you can please add to this i will be very grateful.

Thank you
 
Well, there's at least one other problem:
Code:
sql='''select vid_ID,
Description,from
q.vid order by vid_id desc limit %s'''% (limit)
Even without the %s after q.vid the comma after Description is invalid SQL syntax. Plus, q.vid doesn't look like a proper table name unless you're connected as a user named 'q'.

Basic debugging 101: Print out the SQL and paste it into a SQL interpretter to see if it's valid.
 
Hi,

I have tried that is gave me the same error, am going to check out the debugging SQL link that you gave.

Yes i am connected as a user name

If you can give any other suggestions that can help, again i will be very grateful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top