Solved

Query returning 0 results [500 pts]

Posted on 2006-11-10
3
262 Views
Last Modified: 2013-12-12
I created a table using the following code:

CREATE TABLE si_auth_user (
user_id VARCHAR(10) NOT NULL,
user_password CHAR(32) NOT NULL,

PRIMARY KEY (user_id)
);

INSERT INTO si_auth_user (user_id, user_password) VALUES ('guest', PASSWORD('guest'));
INSERT INTO si_auth_user (user_id, user_password) VALUES ('admin', PASSWORD('admin'));



When I try to run this query, I get 0 results returned:

SELECT user_id FROM si_auth_user WHERE user_id = 'guest' AND user_password = PASSWORD('guest')


What am I doing wrong?
0
Comment
Question by:dprundle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17918259
Your user_password field isn't long enough.

For that matter, it's not recommended to use the PASSWORD() function for user data anyway; use something like MD5().

To see what's going on, try just doing  SELECT PASSWORD('guest')
0
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 500 total points
ID: 17918267
mysql> select * from si_auth_user;
+---------+----------------------------------+
| user_id | user_password                    |
+---------+----------------------------------+
| guest   | *11DB58B0DD02E290377535868405F11 |
| admin   | *4ACFE3202A5FF5CF467898FC58AAB1D |
+---------+----------------------------------+
2 rows in set (0.00 sec)

mysql> select PASSWORD('guest');
+-------------------------------------------+
| PASSWORD('guest')                         |
+-------------------------------------------+
| *11DB58B0DD02E290377535868405F11E4CBEFF58 |
+-------------------------------------------+
1 row in set (0.00 sec)


Sure they don't match.  (-:
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17918405
VoteyDisciple has already revieled the problem that the ifled user_password is not long enough.
apart from that problem, you should NOT use CHAR() datatype, but rather VARCHAR(), in this case VARCHAR(100) for example

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question