Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Query returning 0 results [500 pts]

Posted on 2006-11-10
3
Medium Priority
?
265 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 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