Solved

Query returning 0 results [500 pts]

Posted on 2006-11-10
3
257 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
  • 2
3 Comments
 
LVL 19

Expert Comment

by:VoteyDisciple
Comment Utility
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
Comment Utility
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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 dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now