Results 1 to 7 of 7

Thread: improperly hyperlinked terms

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default improperly hyperlinked terms

    Why doe the following code create a link to the page the script originates from?
    PHP Code:
    <?php
    echo "<a href=>ii</a>";
    ?>
    How can I stop this?
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    either define a url ( href="url/to/desired.file" ) or, if you don't want the anchor to be a link at all, remove the href attribute altogether.

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Here are some more examples:

    For example
    PHP Code:
    <?php
    echo "<a href=>test</a>";
    ?>
    will produce <a href=http://www.animeviews.com/test.php>this</a>

    PHP Code:
    <?php
    echo "<a href=\'http://www.animeviews.com/test.php\'>test</a>";
    ?>
    will produce <a href=http://www.animeviews.com/'http://www.animeviews.com/test.php/'>this</a>

    the following works however.
    PHP Code:
    <?php
    echo "<a href=http://www.animeviews.com/test.php>test</a>";
    ?>
    I might be wrong, but I think that single quotes are normally used in links.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Double quotes are used in links usually

    Code:
    <a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
    This would display "Check out something" and link to the pagehttp://www.site.com/directory/directory.php if there were code to use the ?ID=SOMETHING then the content would be specific to that the address bar would show that as well.

    If you were to do this with php you could do it 2 ways the easiest being just end the php where your outputting html
    PHP Code:
    <?php

    php stuff 

    if () {
    ?>


    <a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
    <?php
    } else {
    ?>

    <a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
    <?php 
    more php stuff
    ?>
    or you could as your doing it


    PHP Code:
    <?php 
    echo "<a href=\"http://www.site.com/directory/directory.php?ID=SOMETHING\">Check out something</a>";
    ?>
    If as it appears your want to go no where though use this

    Code:
    <?php
    echo "<a href="#">ii</a>";
    ?>

  5. The Following User Says Thank You to bluewalrus For This Useful Post:

    james438 (10-20-2009)

  6. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Thanks for the quick and informative responses. Somehow I got it into my head that single quotes were what were needed when creating links.
    To choose the lesser of two evils is still to choose evil. My personal site

  7. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    here is another related problem. Why does
    PHP Code:
    <?php
    echo "<a href=\"www.animeviews.com\">ss</a>";
    ?>
    create a hyperlink to hxxp://www.animeviews.com/www.animeviews.com ?

    I am using double quotes. I am writing a PCRE script that converts most addresses into the hyperlinked form before it is stored in my database.
    To choose the lesser of two evils is still to choose evil. My personal site

  8. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I'm pretty sure that it looks for the "http://" or "https://" when you use a hyper link. But if you were to just leave that part blank, it would take the root directory (I think) and continue off of that.
    Jeremy | jfein.net

  9. The Following User Says Thank You to Nile For This Useful Post:

    james438 (11-05-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •