Tools to Capture and Convert the Web

How do I store a capture in a database?

Captures such as screenshots or animated GIF's can be stored directly into any database. This article will demonstrate how this is done using the PHP language and the MySQL database system. However the same approach should work with different languages and database systems.

A capture can be returned as bytes by using the GetResult method in GrabzIt's API. Once you have these bytes they can then be stored in a database as normal. First create a database table to store the captures in. An example of which is shown below.

CREATE TABLE captures (
id INT NOT NULL AUTO_INCREMENT,
content BLOB NOT NULL,
PRIMARY KEY(id)
); 

Next get the capture as normal and add slashes to the result so that the SQL statement won't fail. Then execute the query to store the capture in the database.

$result = $grabzIt->GetResult($id);

if (!$result)
{
   return;
}
$content = addslashes($result);

$query = "INSERT INTO upload (content) VALUES ('$content')";
mysql_query($query) or die('Error, query failed'); 
Back to SupportMore Web Capture ArticlesCommunity Web Capture Questions
Try all our premium features for free with a 7 day free trial. Then from $5.99 a month, unless cancelled.
  • More Captures
  • More Features
  • More API's
  • Bigger Scrapes
  • Bigger Captures
  • Bigger Everything
Start Free Trial