1

I am developing a php application that needs to query an sqlite database which is not placed in the www folder. I am using the following code to connect.

$db = sqlite_open($path, 0666, $sqliteerror);

but there is some kind of error. My app is placed in httpdocs section. so how can i specify the path to my db?

$path='/srv/smartfox/Server/db/myDB.sqlite';
3
  • Can you elaborate "Some kind of error". It is difficult to read minds these days :) Commented Dec 19, 2011 at 16:07
  • lol it says "server error" when i upload the file but if i dont try to connect the db..then everything goes smoothly. can i know what the exact error is by printing $sqliteerror? Commented Dec 19, 2011 at 16:14
  • @Salmanmahmood I don't know... can you? (i.e. have you tried?) Commented Dec 19, 2011 at 16:34

3 Answers 3

1

Check the following:

  • The PHP process has to have read access to the database file.
  • The PHP process has to have write access to the file and the enclosing folder if you're trying to write to the database (Sqlite might need this even if you're not writing, but I'm not sure about that).
  • You might not have the Sqlite extension enabled. Check it with phpinfo().

Try this:

  • Enable error logging to see what error you get.
  • Try accessing a database inside your httpdocs folder. Does that work?
  • Use PDO to connect to the database.
Sign up to request clarification or add additional context in comments.

Comments

0

By putting the path between apostrophes:

$path='/srv/smartfox/Server/db/myDB.sqlite';

Comments

0

Just check root directory for your script by: $_SERVER["DOCUMENT_ROOT"] and then decide the path for the sqlite file. I think there might be a problem regarding the path. If your control is in 'www' directory than use:

$path = 'srv/smartfox/Server/db/myDB.sqlite';

Hope it might work!!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.