'Warning: sqlite_query() expects parameter 1 to be resource, string given

I've looked all over the place and cant find a solution that helps my case. I hope someone can help?

I have this and receive

Warning: sqlite_query() expects parameter 1 to be resource, string given

It is relating to $dbresult line - so a problem with the query.

function Up(){ 
$dbquery = "DELETE FROM toolList WHERE toolId='".$data['toolId']."'";  
$dbresult = sqlite_query($dbhandle, $dbquery);  
}
     
foreach($result as $data){ 
 print '< a href="'.Up().'">DELETE!< /a>';  
}


Solution 1:[1]

Where is $dbhandle defined? I'm guessing it's a global variable, in which case you have to explicitly mention so within the Up function:

function Up(){ 
  global $dbhandle, $data, $dbresult;
  $dbquery = "DELETE FROM toolList WHERE toolId='".$data['toolId']."'";  
  $dbresult = sqlite_query($dbhandle, $dbquery);  
}

Solution 2:[2]

You are either missing a call to sqlite_open(), or your $dbhandle variable is not available in your function.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 casablanca
Solution 2 dr Hannibal Lecter