Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'charset:iso-8859-7': 0.04; 'elif': 0.05; 'back.': 0.09; 'data:': 0.09; 'happen?': 0.09; 'if,': 0.09; '*only*': 0.16; '......': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'hits': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 're.search(': 0.16; 'selects': 0.16; 'stepping': 0.16; 'sys.exit(0)': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'form:': 0.24; 'month,': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'lines': 0.31; 'helpful.': 0.31; 'but': 0.35; 'to:addr:python- list': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'then,': 0.60; 'name': 0.63; 'header:Reply-To:1': 0.67; 'results': 0.69; 'reply-to:no real name:2**0': 0.71; 'money': 0.72; 'reply-to:addr:python.org': 0.84; 'subject:gets': 0.84; '\xe3\xdf\xed\xe5\xe9': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KrN0hwmN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=ZBT6mux8yFEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=E_FQspuQcigA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=tXfRgeB1Xo0A:10 a=sXtvxZrRNA5T_gVRs-0A:9 a=o3X3QV6JOaEA:10 X-AUTH: mrabarnett:2500 Date: Tue, 11 Jun 2013 23:43:21 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: A certainl part of an if() structure never gets executed. References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> In-Reply-To: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370990594 news.xs4all.nl 16001 [2001:888:2000:d::a6]:38273 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47707 On 11/06/2013 21:20, Νικόλαος Κούρας wrote: > [code] > if not re.search( '=', name ) and not re.search( '=', month ) and not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) ) > elif not re.search( '=', month ) and not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) ) > elif not re.search( '=', year ): > cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year ) > else: > print('''

Πώς να γίνει αναζήτηση αφού δεν επέλεξες ούτε πελάτη ούτε μήνα ή τουλάχιστον το έτος?''') > print( '''''' ) > sys.exit(0) > > data = cur.fetchall() > > hits = money = 0 > > for row in data: > hits += 1 > money = money + row[2] > > ...... > ...... > selects based on either name, month, year or all of them > [/code] > > > The above if structure works correctly *only* if the user sumbits by form: > > name, month, year > or > month, year > > If, he just enter a year in the form and sumbit then, i get no error, but no results displayed back. > > Any ideas as to why this might happen? > What are the values of 'name', 'month' and 'year' in each of the cases? Printing out ascii(name), ascii(month) and ascii(year), will be helpful. Then try stepping through those lines in your head.