Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7936033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:05:27+00:00 2026-06-03T22:05:27+00:00

I am pulling some category names from a table, and I am using htmlspecialchars()

  • 0

I am pulling some category names from a table, and I am using htmlspecialchars() to process the string that I get back for the category name. The problem is that one out of hundreds of category names is being echo’d with a bad closing tag. This is a simplified version of the string I am echoing:

$value['CATNAME'] = htmlspecialchars($value['CATNAME']);

echo '<a href="somepage.php?parms=foo">'. $value['CATNAME']. '</a>';

All of the links are coming out correctly, except the bad one. It is being echo’d as

<a href="somepage.php?parms=foo">AR North/a>

Without the htmlspecialchars() line commented out, it’s output with the correct closing tag. I looked at the string in the table and there’s nothing wrong with it there either. Does this seem like a PHP issue, or should I be looking elsewhere? I am suspecting that maybe there is some javascript messing with the tags, that’s where I plan on looking next.

Thanks.

EDIT: Update

More detailed code with what I am trying now:

        // Convert characters with special HTML significance
        $value['CATNAME'] = utf8_encode($value['CATNAME']);
        $value['CATNAME'] = htmlspecialchars($value['CATNAME']);
        // Print the list item. If the currently selected Id is equal to the category being listed indicated so by marking it

        if ($selectedCat === $value['CATID'])
            echo '<li id="catSel"><a href="page.php?id=' . $value['parm1'] . '&amp;pl=' . $_SESSION['parm2'] . '">' . $value['CATNAME'] . '</a>';
        else
            echo '<li><a href="page.php?id='. $value['parm1']. '&amp;pl='. $_SESSION['parm2']. '">'. $value['CATNAME']. '</a>';

Is still giving me

<li><a href="somepage.php?id=185&amp;pl=10">AR North/a></li>

But if I change the last line to

$value['CATNAME']. '</a>'; to $value['CATNAME']. ' </a>';

I get

<li><a href="catview.php?id=185&amp;pl=10">AR North </a></li>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:05:28+00:00Added an answer on June 3, 2026 at 10:05 pm

    The string may have a hidden delete character (ASCII 127) hidden in it. Try to echo out the string in hex to see if u can find something out of the ordinary. Sometimes it’s a simple encoding issue and encoding the string as utf-8 before running htmlspecialchars may fix it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Entity Framework code first and pulling some data back from our database.
I'm pulling some data from a table using LINQ 2 SQL...one of the pieces
I'm pulling some text passages from a database that have some minimal formatting using
I have two functions that pulling some of content from html and returning it
We are currently porting some php scripts that are pulling datetimes from the facebook
I need some help pulling cell data from table when a user clicks the
I am pulling some data from a mysql table via the following: $result =
I am pulling back some data from the twitter query API, and parsing it
I am pulling some data from mysql database using PHP, now I would like
I am pulling in some information from a database that contains dimensions with both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.