Search code examples
phphref

Echo'd links showing after my web address


Just a quick question obviously has a simple solution, however I am unable to find it...

Would anyone be kind anough to point me in the right direction on why this piece of code is showing up after my directory in the new tab...

echo "<td><a href='$row[link_address]' target='new'>" . $row['link_address']. "</a></td>";

Once the new tab opens it is echo'ing the link after my web address, for example www.mysite.com/$row['link_address'] I am obviously looking for this to be just the link and not a forward slash after my directory.

Any help would be much appreciated.

Thank you!


Solution

  • Absolute links (where the entire URL is in the link) need to start with the protocol part of the link (eg http:// or https://).

    Otherwise, the browser assumes the link is to a directory called abc.com on your domain, rather than to the abc.com domain.