Solved

Query returning 0 results [500 pts]

Posted on 2006-11-10
3
258 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
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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Healthcheck 2 86
PHP_POST() error message 9 45
Is this error or Notice in php error log? 6 32
mysqli 3 23
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

863 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

26 Experts available now in Live!

Get 1:1 Help Now