It seems like sqlite is trying to write a tmp-table file in the directory in which the databasefile resides. Try (at least as a test) to give world write rights to the directory.
If you have the database file in /opt/www/db then :
chmod 777 -R /opt/www/db
This isn't very good security - but try it, just to test if this is indeed the problem :-)