Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Dennis Lee Bieber wrote: > On Sat, 28 Jan 2006 10:14:44 -0800, Kirk McDonald <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>The comma is intentional: the MySQLdb wants the argument(s) as a tuple. > > > The DB-API wants tuples... But my last perusal of the MySQ

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Fred
Perfect again Kirk! Now I will study all this so I actually understand what is happening.. Thanks! Fred -- http://mail.python.org/mailman/listinfo/python-list

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Fred wrote: > OK one more... how would I do a "LIKE" instead of a = in this code? > > cursor.execute("Select * from phone where name=%s order by name", > (form['name'].value,)) > > Right off I think: > > cursor.execute("Select * from phone where name like %%s% order by > name", > (fo

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Fred
OK one more... how would I do a "LIKE" instead of a = in this code? cursor.execute("Select * from phone where name=%s order by name", (form['name'].value,)) Right off I think: cursor.execute("Select * from phone where name like %%s% order by name", (form['name'].value,)) But it blow

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Fred
Thanks Kirk! That worked perfect! And makes perfect since now that I see it... Now that I have the main pieces working I can start expanding from here! Fred -- http://mail.python.org/mailman/listinfo/python-list

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Fred wrote: > Yeah, I already tried that (except you have a , after name. > > Your code produces the same error: > > NameError: name 'name' is not defined > > I know I am close!! Just missing some small thing... > Oh, duh. I forgot something: #!/usr/local/bin/python print "Content-Type: text

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Fred
Yeah, I already tried that (except you have a , after name. Your code produces the same error: NameError: name 'name' is not defined I know I am close!! Just missing some small thing... -- http://mail.python.org/mailman/listinfo/python-list

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Kirk McDonald
Fred wrote: > No matter what I type in the form text box (or even if I leave it > blank) I get all the records. Try this: #!/usr/local/bin/python print "Content-Type: text/html\n" import MySQLdb import cgi db=MySQLdb.connect(host = 'localhost', db = 'phone') cursor=db.cursor() cursor.execute("Se

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Fred
print MySQLdb.paramstyle returns: format I found one example like this: cursor.execute('''Select * from phone where name=%s order by name''',(name)) But I get this in my Apache error log: NameError: name 'name' is not defined Like my last problem I posted, I am sure it is something very simple

Re: MYSql, CGI web page search code not working

2006-01-28 Thread Diez B. Roggisch
> > db=MySQLdb.connect(host = 'localhost', db = 'phone') > cursor=db.cursor() > cursor.execute("Select * from phone where name = name order by name") You don't parametrize the query. The where-clause thus is a tautology, as the name is always the name. Do something like this: cursor.execute("

MYSql, CGI web page search code not working

2006-01-28 Thread Fred
OK, I can now successfully enter data into my MySQL database through my CGI web page. I can click a button and retrieve all the records, but I can not seem to get the search code to work. Below is the web page code and then my Python script. When I click my search button it just gives me all the