By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Drive Letter And A FQFN (Fully Qualified Filename, OS:Windows), PDO

P: n/a
function CreateMyDataBaseFile($FQFN, $UID, $PW) {
$db = "sqlite:" . $FQFN;
$sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);";

$dbh = new PDO($db, $UID, $PW);
$dbh->exec($sql);
$dbh = null;
}

This works as long as a drive letter is not FQFN. For instance,
if, $FQFN = "Z:/mysql/dbn/data.db", PHP replies:

SQLSTATE[HY000] [14]

along with a couple lines of text identifying line numbers and such.

The function above works well if FQFN = "./data.db". But, the
database file must get set up on a different drive.

Thanks.

--
Jim Carlock
Post replies to the group.
May 17 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
*** Jim Carlock escribió/wrote (Thu, 17 May 2007 14:23:42 -0400):
This works as long as a drive letter is not FQFN. For instance,
if, $FQFN = "Z:/mysql/dbn/data.db", PHP replies:

SQLSTATE[HY000] [14]

along with a couple lines of text identifying line numbers and such.

The function above works well if FQFN = "./data.db". But, the
database file must get set up on a different drive.
Drive letters for network drives are not universal. Each user in the same
computer will have different letters. If you run your script through a web
server, the script will not have access to *your* letters but those of the
user the services runs as (normally LocalSystem).

I suggest you try with UNC paths, such as //server/share


--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
May 17 '07 #2

P: n/a
*** Jim Carlock escribió/wrote (Thu, 17 May 2007 14:23:42 -0400):
This works as long as a drive letter is not FQFN. For instance,
if, $FQFN = "Z:/mysql/dbn/data.db", PHP replies:

SQLSTATE[HY000] [14]

along with a couple lines of text identifying line numbers and such.

The function above works well if FQFN = "./data.db". But, the
database file must get set up on a different drive.

"Alvaro G. Vicario" <we*******@NOSPAMdemogracia.comwrote:
: Drive letters for network drives are not universal. Each user in the
: same computer will have different letters. If you run your script through
: a web server, the script will not have access to *your* letters but those
: of the user the services runs as (normally LocalSystem).
:
: I suggest you try with UNC paths, such as //server/share

The only problem there, is that no shares really exist... except the
hidden shares. It's not a networked drive. It's a mapped drive letter
created to shorten a path. Subst.exe was used to create the the drive
letter.

No network paths exist on the system. Group policies were set up to
prohibit network paths I think.

The code works on the physical drives, even the removable drives,
for instance...

function CreateMyDataBaseFile($FQFN, $UID, $PW) {
$db = "sqlite:" . $FQFN;
$sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);";

$dbh = new PDO($db, $UID, $PW);
$dbh->exec($sql);
$dbh = null;
}

CreateMyDataBaseFile("A:/test.db", "admin", "password");

where A: represents a 3.5" disk drive. It just fails on a SUBST
drive (mapped to a folder on another drive).

Thanks for the suggestion.

I've tried tricking it with things like, "./Z:/test.db" and "//Z:/test.db"
but so far no luck.

--
Jim Carlock
Post replies to the group.
May 17 '07 #3

P: n/a
Jim Carlock wrote:
The only problem there, is that no shares really exist... except the
hidden shares. It's not a networked drive. It's a mapped drive letter
created to shorten a path. Subst.exe was used to create the the drive
letter.
Well, why not just specify the original long path?

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 18 '07 #4

P: n/a
*** Jim Carlock escribió/wrote (Thu, 17 May 2007 18:09:56 -0400):
The only problem there, is that no shares really exist... except the
hidden shares. It's not a networked drive. It's a mapped drive letter
created to shorten a path. Subst.exe was used to create the the drive
letter.
Alright... I just figured out you were talking about networks paths.
Anyway, what I said about drive letters being a per-user resource is still
valid in your case. I've just linked a folder to letter M: and I've written
this test script:

<?php

echo `dir M:`;

?>

It works fine under command line (with my credentials) but it can't find
the drive if I run it through my local web server (running as "Local
System"). You can check the credentials of the Apache service running
"services.msc".

If you want to use the drive letter under Apache you must find a way to run
substr as Local System and then make sure that Local System user has write
access to the specified folder. Or you can change the Apache credentials in
the services console so it runs as a know user, then log in as that user
and run substr. It's not a PHP issue.


--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
May 18 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.