PHP not echoing after adding variable to URL

Posted on 2007-10-21
Last Modified: 2013-12-13
Trying to send an verification email and testing generating the url, when I try to add the random number I already have defined earlier in the script $randno, it doesnt work, when I take it out it does. Any ideas?
$to = "";
$new = htmlspecialchars("<a href=''>testing<a/>", ENT_QUOTES);
$randno = rand(0,100);
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
  echo $new;
echo "<a href='" $randno "'>link</a>";
} else {
  echo("<p>Message delivery failed...</p>");
Question by:freqout
    LVL 13

    Expert Comment

    echo "<a href='" $randno "'>link</a>";
    echo "<a href='" .$randno. "'>link</a>";

    (the period is the php string concatenation operator)
    LVL 13

    Accepted Solution

    oh, alternately you can use:
    echo "<a href='$randno'>link</a>";

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now