Jump to content

href html tag output trouble (Newbie)


leonthelion

Recommended Posts

The link text is displaying the right link, but the href tag underneath is truncating...

the following code:

[!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--] <a href=\"http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/d.php?id=".$file."\" title\"File\">http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/d.php?id=".$_COOKIE["file"]."</a><br><br><br></td></tr>
<tr>[!--fontc--][/span][!--/fontc--]

is generating the following html source:

[!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--] <a href="http://domain.com/send/jap/send/d.php?id=" title"File">http://domain.com/send/jap/send/d.php?id=2306d47066299f8cb5f380c4c4435c98</a><br><br><br></td></tr>
[!--fontc--][/span][!--/fontc--]

As you can see, some formatting in the above code is being interpreted against my wishes. If I can only get the href to match the link text, it will work.

I'm quite sure it's a simple syntax error, but can't find which part...
Link to comment
https://forums.phpfreaks.com/topic/12564-href-html-tag-output-trouble-newbie/
Share on other sites

You have one incredibly long link there! At any rate I strongly suggest assigning it to a variable then doing this:
<a href="$link_url">Click Me</a>
You can have your lengthy url that way and avoid some of the problems with quotes inside quotes, so:
$link_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/d.php?id=' . $file ...
I'm not sure what you did after the $file, what with the \ 's I was a little confused. At any rate you should be able to keep concatenating forever.
Thank you for your help.

That solved the problem, but I needed to include the trailing code, so my end result was:

$link_url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/d.php?id='.$_COOKIE["file"];

and then

<a href='$link_url'>some text</a>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.