|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57785 PDO SQLite file with non ASCII char in path
Submitted: 2007-08-14 04:20 UTC Modified: 2020-12-07 14:04 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: fmate144 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: PDO SQLite
PHP Version: 5.6.10 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: fmate144 at gmail dot com
New email:
PHP Version: OS:


 [2007-08-14 04:20 UTC] fmate144 at gmail dot com
I have a simple sqlite database file. If in its path is non ASCII characters, the PDO can not open it!

Reproduce code:
// In c:\x?x\test.php
// Exception: unable to open database file
$db = new PDO('sqlite:test.db3');
// Work good!
$db = sqlite_open('test.db3', 0666, $sqliteerror);

// In c:\xex\test.php both work good.

Expected result:
unable to open database file


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-14 05:01 UTC]
(wrong package selection)
 [2009-02-26 11:29 UTC] iisfirewall at 126 dot com
if the path has no asc char,the pdo_sqlite3 will free work.
 [2014-02-26 11:59 UTC] wcode404 at gmail dot com
Test script:
Create folder (charset windows-1251)

In the command line call a command
C:\тест\test\> php -r "new PDO('sqlite:test.db');"

Expected result:
Should create a database file

Actual result:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1] unable to open database file' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('sqlite:test.db')
#1 {main}
  thrown in Command line code on line 1
 [2015-06-12 12:54 UTC]
-Status: Open +Status: Verified -Package: PDO_SQLITE +Package: SQLite related -Operating System: WinXP SP2 +Operating System: Windows -PHP Version: Irrelevant +PHP Version: 5.6.10
 [2015-06-12 12:54 UTC]
I can confirm this issue for CP-1252 with the reproduce script
given by wcode404 (thanks!).

When the relative path ("test.db") is expanded to a an absolute
path by expand_path[1], the path is not UTF-8 encoded, but later
sqlite3_open[2] is called, which expects an UTF-8 encoded
filename. Using sqlite3_open16 instead would work for me, but that's
likely not an option for portability reasons[3]:

| The default encoding will be UTF-8 for databases created using
| sqlite3_open() or sqlite3_open_v2(). The default encoding for
| databases created using sqlite3_open16() will be UTF-16 in the
| native byte order.

The same problem affects the SQLite3 extension, too.

[1] <>
[2] <>
[3] <>
 [2016-06-27 16:23 UTC]
-Package: SQLite related +Package: PDO SQLite
 [2020-12-07 14:04 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-12-07 14:04 UTC]
This issue is resolved as of PHP 7.1.0; UTF-8 paths are supported
on Windows now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC