Create a sqlite database
This example creates a sample sqlite database and populates it with some data
<?php
//Open/Create sqlite db
if (!($db = sqlite_open(’sample.db’)))
{
die(sqlite_error_string(sqlite_last_error($db)));
}
//create a table and populate with some data
$sql = ”
create table sample (
id integer primary key,
cat text not null,
title text not null
);
insert into sample (cat, title) values (’programming’,'getphp’);
insert into sample (cat, title) values (’sport’, ‘golf site’);
insert into sample (cat, title) values (’programming’,'java site’);
insert into sample (cat, title) values (’search’,'google’);
“;
//handle failure or success
if (!(sqlite_exec($db, $sql)))
{
die(’SQL ERROR: ‘ . sqlite_error_string(sqlite_last_error($db)));
}
else
{
echo ‘Database and table created!’;
}
//tidy things up
sqlite_close($db);
?>
Related posts:
- Build Your Own Database Driven Web Site Using PHP & MySQL (Paperback) “Build Your own Database Driven Web Site Using PHP...
- Ajax and PHP Stock Quote example This is a new source code section so we thought...
- Get Dow Jones stock market data This example retrieves the latest Dow Jones data from Yahoo...
- PHP and MySQL for Dummies (Paperback) Build an online catalog and a members–only site Everything...
- Learning PHP, MySQL, and JavaScript: A Step-by-Step Guide to Creating Dynamic Websites (Paperback) Learn how to create responsive, data-driven websites with PHP,...
Related posts brought to you by Yet Another Related Posts Plugin.
Tags: sqlite, sqlite_close, sqlite_error_string, sqlite_exec, sqlite_last_error, sqlite_open

(1 votes, average: 4.00 out of 5)

















