title: Variable Not Being Sent In Email
body: <p>I'm a bit stumped on this since I'm using the same setup as in another one of my scripts and it works. I'm setting up a link in an e-mail system for users to unsubscribe. My unsubscribe script is the same one i've used over and over so I know it works, but when the e-mails are sent out the e-mail is not in the link. The link should appear in an email as <code>http://example.com/unsubscribe.php?id=ENCODED-EMAIL</code> but it is appearing is <code>http://example.com/unsubscribe.php?id=</code>. If you look through my code all of my variables are filled out and have values so I'm stumped as to why it's not showing in the e-mail.</p>
  
  <p>The variable that should be working is <code>$encodedTo</code>. Any ideas?</p>
  
  <pre><code>require($_SERVER['DOCUMENT_ROOT']."/settings/functions.php");
  require($_SERVER['DOCUMENT_ROOT'].'/php/class.phpmailer.php');
  require($_SERVER['DOCUMENT_ROOT'].'/php/class.pop3.php'); 
  require($_SERVER['DOCUMENT_ROOT'].'/php/class.smtp.php');
  
  if(isset($_POST['submit'])) {
  
  $conn = getConnected("oversizeBoard");
  if(empty($_POST['company'])) {
   echo "Company Name Is Required.";
   exit();
   }
   else {
    $company = mysqli_real_escape_string($conn, $_POST['company']);
   }
  if(empty($_POST['name'])) {
   echo "Contact Name Is Required.";
   exit();
   }
   else {
    $name = mysqli_real_escape_string($conn, $_POST['name']);
   }
  if(empty($_POST['phone'])) {
   echo "Contact Phone Is Required.";
   exit();
   }
   else {
    $phone = mysqli_real_escape_string($conn, $_POST['phone']);
  }
  if(empty($_POST['date'])) {
   echo "Load Date Is Required.";
   exit();
   }
   else {
    $date = mysqli_real_escape_string($conn, $_POST['date']);
  }
  if(empty($_POST['start'])) {
   echo "Start Location Is Required.";
   exit();
   }
   else {
    $start = mysqli_real_escape_string($conn, $_POST['start']);
   }
  if(empty($_POST['end'])) {
   echo "End Location Is Required.";
   exit();
   }
   else {
    $end = mysqli_real_escape_string($conn, $_POST['end']);
   }
  if(empty($_POST['position'])) {
   echo "Position Is Required.";
   exit();
   }
   else {
    $position = mysqli_real_escape_string($conn, $_POST['position']);
   }
  if(empty($_POST['rate'])) {
   echo "Job Rate Is Required.";
   exit();
   }
   else {
    $rate = mysqli_real_escape_string($conn, $_POST['rate']);
   }
  if(empty($_POST['cargo'])) {
   $cargo = "Not Specified";
   }
   else {
    $cargo = mysqli_real_escape_string($conn, $_POST['cargo']);
   }
   if(empty($_POST['height'])) {
   $height = "Not Specified";
   }
   else {
    $height = mysqli_real_escape_string($conn, $_POST['height']);
   }
   if(empty($_POST['width'])) {
   $width = "Not Specified";
   }
   else {
   $width = mysqli_real_escape_string($conn, $_POST['width']);
   }
  if(empty($_POST['length'])) {
   $length = "Not Specified";
   }
   else {
    $length = mysqli_real_escape_string($conn, $_POST['length']);
   }
  if(empty($_POST['weight'])) {
   $weight = "Not Specified";
   }
   else {
    $weight = mysqli_real_escape_string($conn, $_POST['weight']);
   }
  if(empty($_POST['miles'])) {
   $miles = "Not Specified";
   }
   else {
    $miles = mysqli_real_escape_string($conn, $_POST['miles']);
   }
  
  $oversizeQuery = "INSERT INTO postedLoads (company, name, phone, date, start, end, position, rate, cargo, height, width, length, weight, miles)
  VALUES ('$company', '$name', '$phone', '$date', '$start', '$end', '$position', '$rate', '$cargo', '$height', '$width', '$length', '$weight', '$miles')";
  
  if (mysqli_query($conn, $oversizeQuery)) {
      echo "Your Load Has Successfully Been Posted.";
      $emailQuery = "SELECT * FROM subscriptions";
      $emailResult = mysqli_query($conn, $emailQuery);
      while ($subscriber = mysqli_fetch_array($emailResult)) {
          // Begin PHPMailer SMTP Authentication
          $mail = new PHPMailer();
  
          $mail-&gt;IsSMTP(); // set mailer to use SMTP
          $mail-&gt;Host = "localhost";  // specify main and backup server
          // Begin PHP Mailer Headers
          $mail-&gt;From = "loadalert@example.com";
          $mail-&gt;FromName = "Example";
          $mail-&gt;AddReplyTo("loadalert@example.com", "Example");
          $subjectDate =  date('m/d/Y h:i:s A');
          $mail-&gt;Subject = "New Load Alert! You received this alert at " . $subjectDate;
          $mail-&gt;IsHTML(true);  // set email format to HTML
          $to = $subscriber['email'];
          $mail-&gt;AddAddress($to); 
          $encodedTo = rtrim(strtr(base64_encode($to), '+/', '-_'), '=');
          date_default_timezone_set("America/Chicago");
  $mail-&gt;Body = '&lt;!DOCTYPE HTML&gt;';
  $mail-&gt;Body .= '&lt;html&gt;';
  $mail-&gt;Body .= '&lt;body style="padding: 0; padding-top: 20px; margin: 0; font-family: Verdana; text-align: center; background-color: #000;"&gt;';
  $mail-&gt;Body .= '&lt;div style="padding: 10px; background-color: #fff; width: 80%; margin: 10px auto; border-radius: 20px;"&gt;';
  $mail-&gt;Body .= '&lt;h1 style="text-transform: uppercase;"&gt;Hello '.$subscriber['first_name'].'!';
  $mail-&gt;Body .= '&lt;h1 style="text-transform: uppercase;"&gt;You Have Received A New Load Alert!&lt;/h1&gt;';
  $mail-&gt;Body .= '&lt;h2&gt;Company Details&lt;/h2&gt;';
  $mail-&gt;Body .= '&lt;ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;"&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Company: '. $company .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Company Contact: '. $name .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Company Phone: '. $phone .'&lt;/li&gt;';
  $mail-&gt;Body .= '&lt;/ul&gt;';
  $mail-&gt;Body .= '&lt;h2&gt;Load Details&lt;/h2&gt;';
  $mail-&gt;Body .= '&lt;ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;"&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Load Date: '. $date .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Pickup Location: '. $start .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Drop Off Location: '. $end .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Load Rate: '. $rate .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt; Pilot Car Position:  '. $position .'&lt;/li&gt;';
  $mail-&gt;Body .= '&lt;/ul&gt;';
  $mail-&gt;Body .= '&lt;h2&gt;Additional Load Details&lt;/h2&gt;';
  $mail-&gt;Body .= '&lt;ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;"&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Cargo: '. $cargo .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Height: '. $height .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Width: '. $width .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Length: '. $length .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Weight: '. $weight .'&lt;/li&gt;';
  $mail-&gt;Body .= ' &lt;li&gt;Approximate Miles: '. $miles .'&lt;/li&gt;';
  $mail-&gt;Body .= '&lt;/div&gt;';
  $mail-&gt;Body .= '&lt;div style="background-color: #000; color: #fff; padding: 10px;"&gt;';
  $mail-&gt;Body .= ' &lt;p&gt;You have received this e-mail because you are subscribed to your load board. &lt;a href="http://example.com/unsubscribe.php?id="'.$encodedTo.' style="color: #ff0000; text-decoration: none; font-style: italic;"&gt;Click Here&lt;/a&gt; to unsubscribe.&lt;/p&gt;';
  $mail-&gt;Body .= ' &lt;p&gt;To ensure that you receive these e-mails faster, please add us to your address book.&lt;/p&gt;';
  $mail-&gt;Body .= ' &lt;p&gt;Please note: There is no way to guarantee how fast you receive these e-mails. The delivery of your e-mail varies by your e-mail service provider. Please keep in mind that this load board is free, and we do our best to bring this service to you as fast as possible. Thank you.&lt;/p&gt;';
  $mail-&gt;Body .= '&lt;/div&gt;';
  $mail-&gt;Body .= '&lt;/body&gt;';
  $mail-&gt;Body .= '&lt;/html&gt;';
  
      }
  
  } 
  
  else {
      echo "There Was An Error. Please Try Again.";
  }
  
  mysqli_close($conn);
  if(!$mail-&gt;Send())
  {
     echo "Message could not be sent. &lt;p&gt;";
     echo "Mailer Error: " . $mail-&gt;ErrorInfo;
  }
  }
  else {
   echo "You Are Not Authorized To View This Page!";
  }
  </code></pre>