I use this function to check if an element exists in the database.
<?php
$cat=$_REQUEST['cat'];
$db=sqlite_open('./sqlite_database.db',0666,$err) or die();
$query='select * from catsub where cat=\''.$cat.'\'';
$result=sqlite_has_more(sqlite_query($db,$query));
if($result===true ) echo 'Exists'; else echo 'Doesnt Exist';
sqlite_close($db);
?>