SQLite PDO Database Path

I have looked at other sqlite issues in forum and nothing helps.

Moving a test project from local server to EXEOut and cannot get connected to the sqlite database. Here is my connect config:

	$storagelocation = exo_getglobalvariable('HEPubStorageLocation', '');
	//$dbname = $storagelocation.'db2/salespage.sqlite3';
	$dbname = $_SERVER['DOCUMENT_ROOT'].'/db2/salespage.sqlite3';
	$conn = new PDO('sqlite:$dbname');
	$query = "CREATE TABLE IF NOT EXISTS english (english_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, eng001 TEXT, eng002 TEXT, eng003 TEXT, eng004 TEXT, eng005 TEXT, eng006 TEXT, eng007 TEXT, eng008 TEXT, eng009 TEXT, eng010 TEXT, eng011 TEXT, eng012 TEXT, eng013 TEXT, eng014 TEXT, eng015 TEXT, eng016 TEXT, eng017 TEXT, eng018 TEXT, eng019 TEXT, eng020 TEXT)";

I have the folder “db2” inside the “Data” folder which resides with the software exe.

Have even tried using the $storagelocation. just for fun and still no work.

Have both sqlite and pdo_sqlite extensions complied into the exe…

Everything works fine on local server (even tried on line server), but stumped on EXEOut.

Any input be greatly appreciated.

You could test:
$dbname = $_SERVER[‘DOCUMENT_ROOT’].’/Data/db2/salespage.db’;
$conn = new PDO(‘sqlite:$dbname’);

Data being your virtual folder defined in the settings.

Thank you @wayos for input, much appreciated.

Sadly, your suggestion results in same issue I am having.

Seems EXEOut will not work with standard PDO / SQLite. Have tested my code on WAMPP and live server and works without issue. Will not work with EXEOut. Either some type of path issue or EXEOut does not work with PDO.

Try to check the value of $dbname
echo $_SERVER['DOCUMENT_ROOT'].'/db2/salespage.sqlite3';
Also try to move to a folder without spaces in its name to see if this could be the reason.

Thanks for tips and input.

Had already tested the path using echo and looks like this:


Not sure what you mean by move to folder without spaces. Do not have a folder with spaces in use.

If I use standard sqlite without PDO, all is fine using EXEOut. The moment I switch to PDO I get blank pages.

Not trying to sound like broken record, but works flawless using WAMPP and live server (both running PHP 7.2.10).

Out of ideas on my end…

So I have to assume @gdgsupport there is not a solution? Something is certainly wrong when I can use the same code (except for path of course) on XAMPP, PHPDesktop, live server and just tried using phpbrowserbox. All work flawless with exception of EXEOut.

Guess it it is back to using good ole backup plan; nodejs hacked with php:(

Running a business and cannot wait days for help…

I tested it here and it worked(php 7.2).

define('DB_PATH', $_SERVER['DOCUMENT_ROOT'].'/salespage.sqlite3');
$conn= new PDO('sqlite:'.DB_PATH);

The backslash (\)
I see you have an error the correct would be:

Fix (In the script you can put)
define(‘DB_PATH’, $_SERVER[‘DOCUMENT_ROOT’].‘Data\db2\salespage.sqlite3’);
$conn= new PDO(‘sqlite:’.DB_PATH);

One bar can ruin everything.
Take the tests and good luck.

We tested new PDO('sqlite:'.path); and it works fine. Indeed, the \ slash could be problematic: PHP knows how to deal with different \ and / for paths. But SQLite may have a different behavior.

Thank you both @wayos and @gdgsupport

But I am not placing the \ manually (at least on purpose).

The results I am showing is simply using


or echo

echo $_SERVER[‘DOCUMENT_ROOT’].’/db2/salespage.sqlite3’;

They both produce


Beats me. For now have used another method to make my software. Love to get EXEOut working though:) Will have to revisit and see.

Using SQLite on ExeOutput is possible, it’s tricky to understand and I think the documentation should be made clearer. The following steps helped me.

  1. Check the “Use an absolute path for the virtual Data subfolder”
  2. In the text field, replace “X:Data” with the full path to where your SQLite file is e.g
    “C:\Users\My Computer\project\my_app\db_folder” ensure this is where your SQLite file is. likely inside your db folder inside your project app folder e.g. “my_app\db_folder\user_db.sqlite3” so it can be bundled into your EXE file.
  3. In your PHP file, make your connection as below:

dbname = $_SERVER[‘DOCUMENT_ROOT’].’\user_db.sqlite3’;
$conndb = new PDO(“sqlite:$dbname”);

This worked for me.

Thank you @teggsdgreat, will keep this in mind.