Search code examples
phpmysqlobjectrecord

How do I put a MySQL record field result inside a PHP Object?


I have a mailer script, and I want it to e-mail the person that filled out the form. This info is being called from the database. No matter how I try to format this, it doesn't work.

$mail=new PHPMailer;
    $mail->addAddress("[email protected]");
    $mail->addCC("[email protected]");
    $mail->addCC()->{$order_info['user_email']};
    $mail->isHTML(true);
    $mail->Subject=$config["mail"]["subject"];
    $mail->Body=$message;
        if(!$mail->Send()){
            echo "Error sending Email. " . $mail->ErrorInfo;
      } else {
            $URL="view-orders.php"; 
            header ("Location: $URL"); 
    };

I am talking about the 2nd addCC. Is this not possible?


Solution

  • This should work:

    $mail->addCC($order_info['user_email']);

    Or if you are returning objects,

    $mail->addCC($order_info->user_email);