Forum Moderators: coopster

Message Too Old, No Replies

Links From A Database Using Echo

Links are incorrectly being added to page URL

         

oceanwave

4:30 am on Jan 25, 2008 (gmt 0)

10+ Year Member



This should be simple. I am pulling an array of variables from a database. One variable has complete URL links beginning with http:. Let's say link1 in a database row is to Google. The code on my webpage to display the link looks like:

<a href="<?php echo $info['link1'];?>"><?php echo $info['link1'];?></a>

Looking at the example above, the written portion <?php echo $agentinfo['link1'];?> correctly displays Google's URL.
However, the link portion <a href="<?php echo $info['link1'];?>"> incorrectly adds Google's URL to the URL of my webpage.

If I do this: <a href=\"<?php echo $agentinfo['link1'];?>\"><?php echo $agentinfo['link1'];?></a>
Google's URL is still added to the URL of my webpage with %22 written before and after Google's URL.

If I do this: <a href='<?php echo $agentinfo['link1'];?>'><?php echo $agentinfo['link1'];?></a>
Google's URL is added to the URL of my webpage.

How do I write this simple code to display a clean link that is not added to the URL of the page it appears on?

oceanwave

3:12 pm on Jan 25, 2008 (gmt 0)

10+ Year Member



Turns out, my code was correct. The person entering the URLs into the database forgot the 2 slashes in the URL.