Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Dean Kennedy
Dean Kennedy
4,491 Points

Code error while creating new admin user

I have the function detailed below which adds a new admin user and password to the database. The issue however is that the MD5 password differs from that when I create the password through command line. Anyone have any ideas where I am going wrong?

function new_admin($adminarr) { global $dbh;

$sql = "INSERT INTO admins (admins_uname,admins_pwd) values (?,md5(?))";
$data = array($adminarr['admins_uname'],$adminarr['admins_pwd']);
$sth = $dbh->prepare($sql);
try {
    $sth->execute($data);
} catch (PDOException $e) {
    error($e, $sql);
}

}

Dean Kennedy
Dean Kennedy
4,491 Points

Not to worry, error was in HTML