Jump to content

[SOLVED] PHP and Mysql help


blackwolf23

Recommended Posts

Hello,

 

I'm having trouble querying my database for the email address of a specific user and using that email address in the php mail function to send the user their new password. The below code keeps generating the error 'Call to undefined function mysqli_fetch_object() in Functions.php on line 138' WHich I can't seem to figure out why(I am still new to php).

 


function email_passwd($Username,$test)
{
  //Get the email address of the user from the db
  $conn = connect();
   $query = "SELECT Email FROM Users WHERE Username  = '".$Username."'";
   $result = mysql_query($query);
  $row = mysqli_fetch_object($query);

  //Email the user
    $to      = '$row->Email';
    $subject = 'Password Reset';
    $message = "Your password has been reset to $test";


    mail($to, $subject, $message);

}

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/54229-solved-php-and-mysql-help/
Share on other sites

I think if i am right here a mail function has 4 parameters.

 

$headers = 'From: ME <[email protected]>' . "\r\n" .
    'Cc: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion() ."\r\n".
    'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $to      = '$row->Email';
    $subject = 'Password Reset';
    $message = "Your password has been reset to $test";


    mail($to, $subject, $message,$headers); 

ok it depends on u how many parameter u want to pass u r right 3 r required other is optional,

But if u mention it ur mails will not go to junk folder or spam folder.

 

now come to ur point.

$to      = '$row->Email';

 

should be:

$to= $row->Email;

 

Confirm Email field in db, is Email not email.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.