I suppose it is a separate database table called “profile” that you want to access there? This does not belong to WordPress, so I’m just wondering.
But I tried to recreate this with the WordPress tables. There it works without problems. Example:
$output = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM wp_users WHERE user_login ='%s';", 'username' ) );
$hashedPass = $output->user_pass;
var_dump($hashedPass);exit;
Note:
You used the $wpdb->prepare() function incorrectly. You need to use a placeholder here and add its value as a parameter. Have a look at my example.
In my example the encrypted password comes out from the database including “$”. If it doesn’t happen with you, it probably has nothing to do with this code you showed but rather with the way you use $hashedPass then.
Thanks, the var dump showed the variable with the dollar signs! Though sadly nothing seemed to change with the functionality. What I’m trying to do, is I have the hashed password in the database and I have the user enter the password into a form. Im trying to check if they entered the correct password. To do this I am using the password_verify() function, which is built into PHP.
$output = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM profile WHERE Name = '%s';",$name ) );
$hashedPass = $output->Password;
$result = password_verify($password, $hashedPass);
For some reason $result never is 1. Unless I am checking for it to be 1 wrongly.
Heres the if statement:
if($result == 1){
password_verify will not work for salted hashes. Are these salted hashed passwords? I can’t tell since you are using a non-Wordpress database table.
Maybe a PHP forum would be better suited for your question as I don’t see any connection to Wordress at the moment.