0

I have this piece of code that should return the value of the password from the db and match it with the password entered. I appended the characters on this line to match the formatting of the result that it printed.

appended_y= "(u'" + y + "'y,)"

it even though the two print out the same value the if statement rejects it and always falls to else, Can anyone point me down the right path?

print "Welcome to the online bookstore login!"
 x = raw_input('Please enter your user id. ')
 y = raw_input('Please enter your password. ')
 appended_y= "(u'" + y + "'y,)" 
 z = "SELECT password FROM members WHERE userid = %s"
 self.cursor.execute(z,(x,))
 pw=(self.cursor.fetchone())
 if appended_y == pw:
 self.member_menu()
 else:
 print "Incorrect name or password. Aborting connection"
asked Dec 3, 2012 at 6:02
4
  • 1
    Look into the type of pw. It may be a string inside a list or tuple. Commented Dec 3, 2012 at 6:45
  • It was a tuiple instead of a string. :) Commented Dec 3, 2012 at 6:47
  • @vpit3833 Why did you delete your answer? It was correct! Commented Dec 3, 2012 at 6:58
  • @glglgl, it was a mistake. thank you for pointing out. Commented Dec 3, 2012 at 7:01

1 Answer 1

1

Look into the type of pw. It may be a string inside a list or tuple.

answered Dec 3, 2012 at 6:55
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.