Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is my URL prefixed on <a href ...> links? 1

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
I came across this rather interesting problem/behavior.

For the sake of argument, lets say the local URL is


Displaying content from a MySQL table, one of the field holds an URL entry.

If the entry reads


when shown on screen using following code:

Code:
echo '
<td><a href="' . $row["MemberURL"] . '" target="_new">' . $row["MemberURL"] . '</a></td>';

PHP appears to add (as a prefix) the local URL thus attempting to open URL as


Why is this?

I edited the field and changed it to


and it does what's expected ... no prefix is added to the URL.

Regards,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
This is not PHP but rather HTML. If you specify a protocol in your link reference, it is assumed that you want to point to a local resource. The URL could be a valid folder on your server and so it will assume that is what you want. Only if you specify a protocol it will know that your link is a different website. You can try that with a static file as well (just type into href="" for a link in an html file and the same will happen).

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
That makes sense. I edited my code to check for if http:// is part of field ... if not, adds it in ... otherwise, it does nothing.

Thanks,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top