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

  • Home
  • SEARCH
  • 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 495615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:36:37+00:00 2026-05-13T05:36:37+00:00

How best to store the html for embedding? the only ways I can think

  • 0

How best to store the html for embedding?

the only ways I can think of are:

take the embed html and add <?php echo $var1; ?> where the id’s go then store it in the db and use Eval to execute it.

or

insert a strange combination of characters to act as a marker to be replaced in php by the id’s.

  • 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-05-13T05:36:37+00:00Added an answer on May 13, 2026 at 5:36 am

    Option #2 is much safer – just in case someone manages to execute a SQL injection attack against your DB, they can’t then exploit your embedding operation to execute injected PHP on the server side. The best they could hope for would be a phishing or XSS attack.

    Another alternative is to format the appropriate data in XML and store in the database an XSLT to transform the data into the right embed code. That’s probably overkill for your case, but more scalable and less error-prone than either of the above.

    EDIT: Skeleton code for XML version

    XML

    <video>
      <url>http://example.com/video.flv</url>
    </video>
    

    XSLT

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" />
      <xsl:template match="video">
        <xsl:element name="embed">
          <xsl:attribute name="src"><xsl:value-of select="url/text()" /></xsl:attribute>
          <xsl:attribute name="width">500</xsl:attribute>
        </xsl:element>
      </xsl:template>
    </xsl:transform>
    

    PHP

    // assuming the XSLT above is stored in SomeTable.transform, and the above XML has been stored in $xml_text
    $xml_doc = new DOMDocument();
    $xml_doc->loadXML($xml_text);
    
    $xsl_doc = new DOMDocument();
    $xsl_doc->loadXML(GetXSLT("flv"));
    
    $processor = new XSLTProcessor();
    $processor->importStyleSheet($xsl_doc);
    echo $processor->transformToXML($xml_doc);
    
    function GetXSLT($type)
    {
        $db = mysql_connect("user", "password", "host"); // not sure if I got the order right here, but whatever
        $res = mysql_query("SELECT transform FROM SomeTable WHERE type = '$type'"); // should use parameters instead of directly embedding the type here to avoid bugs and exploits, but whatever
        $array = mysql_fetch_assoc($res);
        return $array['transform'];
    }
    

    The nice part about this is that you can create a class to generate the input XML, and it can contain all the parameters you want to pass to your <embed> tag. If you don’t add processing instructions to your XSLT to handle them, they’ll be silently ignored. Make one class to generate the basic XML, and a subclass per media type you want to display, and generating the XML to pass the transforms should be easy.

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

Sidebar

Related Questions

I want to convert a string to HTML entities/special characters so that I can
which is the best primary key to store website address and page URLs? To
I'm struggling to work out how best to do what I think I want
I recent wrote this post: How best to store VERY large 2D list of
My website is XHTML 1.1, and I had added 'rel' attributes to the <li>
Please forgive a question that has been addressed in some form or fashion previously.
Suppose (for the sake of argument) that I have a view class which contains
I am working on a web crawler. I am using the Webbrowser control for
I never really put too much time on optimizing website. Sure i put script
Note: This is a follow up to this question . I have a legacy

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.