Get a Free Trial

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');