SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP not producing correct link in site

    I am having a very weird problem with creating a link with command varbiles. Link is created correctly when view html code, but truncated when clicked on.

    PHP Code as follows:
    -------------------
    if ($ad <> "") {
    echo "<TR><TD>Season 1 All:</td><td>";
    echo "<a href=statlogs.php?st=";
    echo $st;
    echo "&en=";
    echo $en;
    echo "&ep=";
    echo $epname;
    echo ">";
    echo $ad;
    echo "</td></tr>";
    }

    ---------------------
    Link Produced when "Viewing Source HTML from IE which is correct.
    ---------------------
    statlogs.php?st=2006-06-17 14:56:00&en=2006-06-17 15:57:00&ep=The Enemy Within

    ---------------------
    Link when actually clicked on.
    ---------------------
    statlogs.php?st=2006-06-17

    ---------------------

    Thanks in advance for any assistance on this problem.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is not a php problem, your html is incorrect.

    html attributes must be quoted if the value contains whitespace
    Code:
    bad
    <a attribute=how would the browser know where the value ends and the next attribute starts if you dont use quotes?>
    good
    <a attribute="how would the browser know where the value ends and the next attribute starts if you dont use quotes?">

    also, you putting a <a> tag directly inside of a <tr> tag, which is also not valid html, and you may run into display problems with different browsers. you should put the tag inside of a <td> tag

  3. #3
    SitePoint Member
    Join Date
    May 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unable to use Quotes, it is part of being inside of the PHP Code. If I do, the PHP DOES not work.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use quotes inside of quotes, you just need to escape them or use a different quote.

    PHP Code:
    echo "<TR><TD>Season 1 All:</td><td>";
    echo 
    "<a href=\"statlogs.php?st=";
    echo 
    $st;
    echo 
    "&en=";
    echo 
    $en;
    echo 
    "&ep=";
    echo 
    $epname;
    echo 
    "\">";
    echo 
    $ad;
    echo 
    "</td></tr>";


    // or use single quotes when you dont need to expand variables
    echo '<TR><TD>Season 1 All:</td><td>';
    echo 
    '<a href="statlogs.php?st=';
    echo 
    $st;
    echo 
    '&en=';
    echo 
    $en;
    echo 
    '&ep=';
    echo 
    $epname;
    echo 
    '">';
    echo 
    $ad;
    echo 
    '</td></tr>'
    see the manual for details
    http://www.php.net/manual/en/language.types.string.php


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
  •