Secure MySQL Access md5()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

Secure MySQL Access md5()

Post by rxsid »

Hi all,

I've got:

WinNT
php 4.3.1
phpmyadmin 2.5.6
MySQL 4.0.18-nt

I can connect to my db via my php script using:

Code: Select all

$connection = mysql_connect ("localhost", "root", "")
That works no problem.

This will not work however:

Code: Select all

$somePass = md5("somePass"); 
$connection = mysql_connect ("localhost", "someID", $somePass)
gives me:


Access denied for user: 'someID@localhost' (Using password: YES)

I set someID up in the db using phpmyadmin, with it's password using the md5() function. I can see via phpmyadmin that someID does indeed have a 32 byte encrypted password stored.

I can then compare the stored md5 password to the md5 password I'm passing to try to connect...via $somePass. The encrypted passwords match exactly.

Why wouldn't the match be confirmed...allowing me to connect?

Thanks!
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Try:

Code: Select all

$connection = mysql_connect ("localhost", "someID", "32charmd5passwordvalue")
The error message is because the pass is wrong, so you jsut need to try different methods of inserting the pass. Make sure theres no whitespace.
Post Reply