Page 1 of 1

php in my html link doesn't work

Posted: Sat Apr 25, 2009 3:02 pm
by soundengine
Hi everyone, I am trying to echo a variable within a plain html link, but it doesn't work. My link looks like this:

Code: Select all

<a href="xxxxxxx.myurl.net/?tid=<?php echo $var; ?>">some text here</a>
I know that php is running because when I use this on it's own:

Code: Select all

<?php echo $var; ?>
it displays the value of my variable $var, but it doesn't work in my link. I am new to php, and I have a feeling that there is some setting on my Apache Linux server that is set incorrectly. Perhaps in my setup file. You can see my php setup here - http://www.stephenpanderson.com/phpinfo.php

When I mouseover the link I see the link containing the php code unprocessed. I should be seeing the value instead.

when I view the source of my page the end of my link looks like this:

Code: Select all

.net/?tid=%3C?php%20echo%20$var;%20?%3E
Any help would be very appreciated. I am a beginner with php.

Thanks,
Steve

Re: php in my html link doesn't work

Posted: Sat Apr 25, 2009 3:49 pm
by MasterBeta
Strange.
What happens if you try this.

Code: Select all

<?php echo "<a href=\"xxxxxxx.myurl.net/?tid=$var\">some text here</a>"; ?>

Re: php in my html link doesn't work

Posted: Sat Apr 25, 2009 4:16 pm
by soundengine
The php link works that you showed me, thanks. But how can I figure out what's wrong with my regular html url with just the php variable? I know that others are using that format and it's working for them.

Any ideas?

Re: php in my html link doesn't work

Posted: Sat Apr 25, 2009 4:28 pm
by MasterBeta
Somehow your opening php tag "<?php" is not being recognized. Make sure you are using valid html. http://validator.w3.org/.
I doubt there is a problem with your php configuration though. I'm not really sure. Good luck!

Re: php in my html link doesn't work

Posted: Sat Apr 25, 2009 6:44 pm
by McInfo
soundengine wrote:You can see my php setup here - http://.../phpinfo.php
A gift to crackers everywhere, that is.

Edit: This post was recovered from search engine cache.