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
Share on other sites

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

 

$headers = 'From: ME <support@domain.com>' . "\r\n" .
    'Cc: cccc@yahoo.com' . "\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); 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.