I am trying to send an email using php mail, however, when using an anchor tag, the link does not go past the single quote (‘) if it is present in the filename.
Here is the line of code where the trouble arises:
$message .= "<tr><td><strong>View LOA:</strong> </td><td><a href='http://myurl.com/loa/" . $myloa . "'>" . strip_tags($myloa) . "</a></td></tr>";
($myloa is pulled from my database. I have multiple files uploaded on my server and save the file names in my DB.)
In the email, $myloa can be read as, for example, Alex’s LOA.pdf
However, if trying to click it (since it is anchored), the link only goes up to Alex. So the link looks like this: http://myurl.com/loa/Alex instead of http://myurl.com/loa/Alex‘s LOA.pdf
How can I fix this? Thanks.
Here is my full code:
$emailloa = $_POST['emailloa'];
$to .= "" . strip_tags($emailloa) . "";
$subject = "The " . strip_tags($name) . " LOA";
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Sent by:</strong> </td><td>" . strip_tags($_SESSION['user']['first']) . " " . strip_tags($_SESSION['user']['last']) . " </td></tr>";
$message .= "<tr><td><strong>View LOA:</strong> </td><td><a href='http://myurl.com/loa/" . $myloa . "'>" . strip_tags($myloa) . "</a></td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
What if you swapped the single and double quotes?
I wonder if the double quotes are throwing off the interpreter: http://php.net/manual/en/language.types.string.php