I am trying to see if there is an existing row in my sqlite database and if not add it. But something is wrong with my query. I hope someone can spot my error.
Specifically I thin the error is in the query line:
$query = 'SELECT * FROM plant WHERE common_Name = '. $commonName . ' AND latin_Name = '. $latinName . 'AND url = '. $URL ;
Thank you, Todd
// set path of database file
$file = "db/plants.db";
// create database object
$db = new SQLiteDatabase($file) or die("Could not open database");
// see if the EXACT same tag exists
$query = 'SELECT * FROM plant WHERE common_Name = '. $commonName . ' AND latin_Name = '. $latinName . 'AND url = '. $URL ;
$result = $db->query($query) or die("Error in query");
$rows = sqlite_num_rows($result);
if($rows>0) return; //do not add it
// generate query string
$query = 'INSERT INTO plant (common_Name, latin_Name, url) VALUES("'.$commonName.'","'. $latinName.'","'.$URL.'")';
// execute query
// return result object
$result = $db->query($query) or die("Error in query");
// destroy database object
unset($db);