Jump to content

Recommended Posts

Hello,

 

I have a bit of a problem with a simple message board using a SQLite database.

 

When my script queries:

 

SELECT * FROM posts ORDER BY id ASC

 

It works absolutely fine.

 

When I try to:

 

sqlite_query($handle, "INSERT INTO posts (name, post, date) VALUES ('" . $message_name . "', '" . $message_msg . "', '" . $message_date . "')") or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));

 

It gives me a error saying:

 

Warning: sqlite_query() [function.sqlite-query]: unable to open database file in *script location* on line 24
Error in query: unable to open database file.

 

The whole condition is:

 

if (isset($_POST['name']) && isset($_POST['msg'])) {
$message_name = $_POST['name'];
$message_msg = $_POST['msg'];
$message_date = date("d/m/y");

sqlite_query($handle, "INSERT INTO posts (name, post, date) VALUES ('" . $message_name . "', '" . $message_msg . "', '" . $message_date . "')") or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));

echo '<b>Your post was successful!</b><br/>' ;
}

 

Is there something wrong? Am I using the strings wrongly? Is there a error in the query?

 

Thanks for any help.

Since the query is generating an error about opening the file, best guess is that there is no valid/error-free sqlite_open() statement prior to the query.

 

It would really take seeing all the relevant code for anyone one to be able to see what might be causing the problem or to be able to duplicate it on their own system.

  • 1 year later...

Hello Dewd,

 

i Had the same problem on my linux-System. My databases are in the directory "sqlite". The databases had the "0777" permissions. But the directory "sqlite" himself had the "0755" permissions.

 

A "chmod 0777 sqlite" had solved the problem.

I hope, it solves your problem too.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.