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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:42:50+00:00 2026-06-13T04:42:50+00:00

I have a php script that will parse html page content link and view

  • 0

I have a php script that will parse html page content link and view but I need to know how to store this content in the sqlite3 database any suggestion?

include_once('simple_html_dom.php'); //PHP Simple HTML DOM Parser library  
$html = file_get_html('www.website.com');  

// Find all article blocks
foreach($html->find('div.postbody') as $article) {
 $item['details'] = $article->find('div.content', 0)->innertext;
 $articles[] = $item;
}
print_r($articles); 

try {

$db = new SQLite3('db/mysqlitedb.db');
$db->exec// what type of table should i create
$db->exec// how tell db to store html content from $articles
$result = $db->query('SELECT bar FROM gg');
var_dump($result->fetchArray());

    /* Close connections to Database */
    $db = NULL;
}

catch( PDOException $e ) 
{

    /* Print Error-Messages */
    echo $e->getMessage();
} 
  • 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-13T04:42:51+00:00Added an answer on June 13, 2026 at 4:42 am

    Typically you will create just one table to store all fragments in, not a table per fragment. Thus, the bare minimum of fields you will need in that table are something to identify the fragment, and the fragment itself. Based on your requirements you may want to add extra fields like the datetime the fragment was inserted, the inserter’s userid, etc.

    The fragment will be stored as TEXT (a large object datatype that can contain text information) and for simplicity’s sake I’ll use an INTEGER field as identifier. Depending on how you will want to retrieve the fragments you can also use a short string, eg a VARCHAR

    CREATE TABLE fragments(
        identifier INTEGER,  -- a unique identifier
        fragment TEXT        -- the fragment
    );
    

    Next, in that collection of codelines you included in your question you are using the native SQLite driver wrapped in a PDO exception. It is highly doubtful that that is going to work properly. I suggest you stick to PDO and to prepared statements. Don’t even consider using cobbled-together literal INSERT statements, especially not in this case where you are inserting html fragments. or in any other case for that matter, preparedstatements are the only water- and bulletproof defense against sql injection attacks and related mischief.

    // open the db.  as this is relatively costly it's typically done outside any loops 
    // in the rest of the code
    $dbh=new PDO('sqlite:./db/mysqlitedb.db') or die("failed to connect to db");
    
    // let's assume $item contains the fragment and $identifier 
    // was initialized with some key value in the mean time
    try{
       $stmt = $dbh->prepare("INSERT INTO fragments (identifier, fragment) VALUES (?, ?)");
       $stmt->bindParam(1, $identifier);
       $stmt->bindParam(2, $item);
       $stmt->execute();
    } catch(PDOException $e) {
       echo $e->getMessage();
    }
    

    That’s the basic setup. Can’t think of a unique numeric key for these fragments? No problem, change identifier’s type to VARCHAR in the table definition.

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

Sidebar

Related Questions

Ok guys.. I have a HTML i need to parse into a php script
I have a simple PHP script that will either serve up a streaming ASF
I have a PHP script running on XAMPP in Windows XP that will open
I have a PHP script that very much like a commenting system, but requires
So I have this php script that output an html table with data about
I need to write a script that takes a link and parses the HTML
Just say I have a file configuration.xml that a php script needs to parse
I have php script that creates a temporary watermark image for users that are
I have a php script that inserts data from an Android app into a
I have a php script that watches for the newest json file in a

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.