I tried to edit ProfileComments2.php to send an email instead of a PM but I can't get it to work....

I'm not a PHP programmer so I don't understand what I'm doing hehe
This is what I have done (sorry if it is not allowed to edit the code...):
// Send email to the user to let them know someone left a comment on their page
if ($userid != $user_info['id'] && $approved == 1)
{
// Lookup the user name's
$dbresult = $smcFunc['db_query']('', "
SELECT
real_name, email_address
FROM {db_prefix}members
WHERE id_member = " . $user_info['id']);
$row = $smcFunc['db_fetch_assoc']($dbresult);
$smcFunc['db_free_result']($dbresult);
$mem_email = $row['email_address'];
require_once($sourcedir . '/Subs-Post.php');
sendmail($mem_email, str_replace("%s", $subject, $txt['pcomments_notify_pm_subject']), str_replace("%s", $scripturl . '?action=profile;u=' . $id, $txt['pcomments_notify_pm_body']));
}
// Redirect back to the profile
redirectexit('action=profile;u=' . $userid);
}
With this edit the 'poster' of the comment receives an empty email. So its selecting the wrong email address.
Is it possible for someone to make this work? I'll be very thankful!
Thanks in advance,
Vincent