Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using mysql_fetch_assoc to create anchor tag - will not validate

    I have code that retrieves data from a mysql DB. The value retrieved is passed to another page. The link text is also the value retrieved from the DB.

    Here is the code snippet:

    Code:
    <?php while($row=mysql_fetch_assoc($result)):?> 
      <tr>
        <td><a href="WelcomeBack.php?WelcomeName=<?php echo $row['Welcome_Name']; ?>"><?php echo $row['Welcome_Name']; ?></a></td>
        <td><?php echo $row['Welcome_Desc']; ?> </td>
      </tr>
    <?php 	endwhile; ?>
    This code appears to work correctly. The problem is that it doesn't validate using XHTML Strict 1.0. I'm getting multiple errors, such as :

    XML Parsing Error: Unescaped '<' not allowed in attributes values
    XML Parsing Error: attributes construct error

    How can I code the above to meet XHTML strict compliance?

    Thanks.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Could you post a link to your page?
    Anyway try
    PHP Code:
    <td><a href="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Welcome_Name']); ?>"><?php echo htmlentities($row['Welcome_Name']); ?></a></td>
        <td><?php echo htmlentities($row['Welcome_Desc']); ?> </td>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply.

    My code is local on my PC right now, no link...

    I'm still getting the following validation errors:

    Code:
    -----------------------------------------------------------------
    #  Warning  Line 75, Column 62: character "<" is the first character of a delimiter but occurred as data
    
    …ref="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Welcome_Name
    
    This message may appear in several cases:
    
        * You tried to include the "<" character in your page: you should escape it as "&lt;"
        * You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
        * Another possibility is that you forgot to close quotes in a previous tag.
    
    -----------------------------------------------------------------
    # Line 75, Column 61: XML Parsing Error: Unescaped '<' not allowed in attributes values
    
    …href="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Welcome_Nam
    
    ------------------------------------------------------------------
    # Error Line 75, Column 61: XML Parsing Error: attributes construct error
    
    …href="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Module_Nam
    
    ------------------------------------------------------------------
    # Error Line 75, Column 61: XML Parsing Error: Couldn't find end of Start Tag a line 75
    
    …href="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Welcome_Nam
    
    ------------------------------------------------------------------
    # Error Line 75, Column > 80: XML Parsing Error: Opening and ending tag mismatch: td line 75 and a
    
    …s.php?WelcomeName=<?php echo htmlentities($row['Welcome_Name']); ?>"><?php ech…
    
    ------------------------------------------------------------------
    # Error Line 75, Column > 80: XML Parsing Error: Opening and ending tag mismatch: tr line 74 and td
    
    …s.php?WelcomeName=<?php echo htmlentities($row['Welcome_Name']); ?>"><?php ech…
    Thanks again.

    Quote Originally Posted by abduraooft View Post
    Could you post a link to your page?
    Anyway try
    PHP Code:
    <td><a href="WelcomeBack.php?WelcomeName=<?php echo htmlentities($row['Welcome_Name']); ?>"><?php echo htmlentities($row['Welcome_Name']); ?></a></td>
        <td><?php echo htmlentities($row['Welcome_Desc']); ?> </td>

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Are you validating your page with php codes as such? You need to view that page via browser and get parsed html output.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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