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 9120229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:34:50+00:00 2026-06-17T05:34:50+00:00

In a PHP function I am grabbing random chunks of HTML from my MySQL

  • 0

In a PHP function I am grabbing random chunks of HTML from my MySQL database that may or may not be well formed. An example is:

<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Heres something to display<br><br>Thanks,<br><br>

I am then returning this chunk of HTML from the PHP function and echoing what is returned onto the page into a <div> holder.

The problem I am having is that the above displays properly but because it doesn’t have closing tags it is playing havoc with the DOM when it is displayed. I can’t control how the HTML is formed because it comes from random email responses. My question is, is there anyway to encapsulate this chunk of HTML and cut it off from the rest of my page? Are there tags I can wrap this HTML in besides <div> that will ensure that regardless of how well formed it is, it will display but not interact with the rest of the page?

  • 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-17T05:34:51+00:00Added an answer on June 17, 2026 at 5:34 am

    You can limit the damage caused by running it through a DOM parser. Example:

    libxml_use_internal_errors(true);
    $dom = new DOMDocument();
    $dom->loadXML("<root>".$your_malformed_html."</root>");
    $reformatted_html = substr($dom->saveXML(),6,-7);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm grabbing a datetime from a MySQL database using php. In mysql the datetime
I have a PHP function that extract dat of an invoice from DB. The
A PHP function I am writing pulls a small bit of HTML data from
I have a JS/PHP piece of code that selects from a database, does some
i m grabbing image paths from MySQL via php and then json_encode and with
I created a PHP function that will automatically turn URLs into links, link Twitter
Is there any php function in our time, which generates absolutely unique, random string?
I have a PHP function that builds a JSON array via $jsonArray= array(); for
Basically, I'm grabbing contents from a PHP file. I check it every 5 seconds.
$.ajax seems to be broken for me: $.ajax({url:'getGalleries.php', datatype:'jsonp', success: function(data){ $('#galleries').html(''); $.each(data,function(key,value) {

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.