Forum Moderators: coopster

Message Too Old, No Replies

Question about inserting variables into a banner link

Shows my domain as the link instead of my link

         

jackten

9:56 pm on Sep 21, 2007 (gmt 0)



Greetings all, I hate asking these sort of newb questions but I've looked around and I've been fiddling with this dumb issue for longer than I care to admit :/

Here is the code I've been using, though I did change it a few times but it always gave the same results :

----
echo "<a href=\"".$url."\"><img src=\"http://www.mydomain.com/images/".$title1."_logo.gif\" alt=\"Website of $title1.\" /></a>";
----
This shows the banner with a link in it, but the problem is that the link it gives is : www.mydomain.com/urlvariable instead of the proper url. This seems like such an easy thing to fix but I can't figure it out.

Any help, please?
Would be very appreciated.

cameraman

1:30 am on Sep 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, jackten!

I don't think the problem is in the line you posted, I think there's something going on where you assign the value to $url.

jackten

6:58 am on Sep 23, 2007 (gmt 0)



Thank you for your reply.
That's what I really don't understand : if I do an echo on $url, it gives the proper value. It just adds it to http://www.example.com/urlvariable instead of being its own new url link. I can't understand why because it seems right and it should work :\ Fooling around, I noticed that if you do <a href=""> it links to your website (at least in my tests). This seems like this is what's happening and it then adds my variable at the end, but it shouldn't be.

Anyone else has an idea? I guess I can work around it by adding each url manually but it seems silly since I'm reading the database to get those websites' info anyway..

[edited by: dreamcatcher at 7:40 am (utc) on Sep. 23, 2007]
[edit reason] Use example.com, thanks. [/edit]

cameraman

9:32 am on Sep 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I must be misunderstanding.
Are you saying that "urlvariable" is the correct value, but instead of the 'correct' (I added spaces so the forum wouldn't make them 'clickable'):
http:// otherdomain.com/urlvariable

you're getting
http:// mydomain.com/urlvariable

?
If that's true, then it sounds like you're using a relative url, and your browser is adding the domain for you.
If you want to point to some other domain, you need to supply an absolute url:
$url='http://otherdomain.com/urlvariable";

echo "<a href=\"".$url."\">. . . . .

Am I still way off?