SQLite problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

SQLite problem

Post by RTT »

Hi, I'm getting this error

Code: Select all

Warning: sqlite_query() їfunction.sqlite-query]: attempt to write a readonly database in /some/path/sqlite.class.php on line 42
create table failed
when I run the following code:

Code: Select all

if($yada = new sqlite_db('/some/path/test.sqlite') == TRUE) {
		
		
		
		$sql = "CREATE TABLE users (
		       id INTEGER PRIMARY KEY,
		       uname STRING UNIQUE,
		       passwd STRING,
		       email STRING,
		       active INTEGER)";
		    
		       
		
		echo "trying to create table with ".$sql."";
		
		if($yada->sqlite_query($sql) == FALSE) {
			
			echo "create table failed";
		} else {
			
			echo "create table success";
		
		}
I see something in the PHP manial about the mode parameter to sqlite_open being ignored:
The mode parameter specifies the mode of the file and is intended to be used to open the database in read-only mode. Presently, this parameter is ignored by the sqlite library. The default value for mode is the octal value 0666 and this is the recommended value to use if you need access to the errmessage parameter.


Any help regarding the read-only error problem GREATLY appreciated :)
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

Post by RTT »

Update:

Code: Select all

<?PHP

if(!$sqlite_db = sqlite_open('yada.db', 0666, $err)) 
	die($err);


?>
produces the following:
Warning: sqlite_open() [function.sqlite-open]: unable to open database: /usr/home/rtt/public/bitscript/yada.db in /usr/home/rtt/public/bitscript/test.php on line 3
unable to open database: /usr/home/rtt/public/bitscript/yada.db
Could this be a permissions thing? Apache runs as 'nobody', maybe 'nobody' doesn't have permission to write a file into my home dir? Hmm........
Post Reply