Odd database creation problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gunder
Forum Newbie
Posts: 1
Joined: Sun Jan 20, 2008 5:00 pm

Odd database creation problem.

Post by gunder »

Hello everyone, I'm using the latest version of WAMP on WinXP. I'm learning about Non-Relational Databases but I'm getting some weird permissions error and I don't know why. I should mention that my internet isn't working at home and I'm on a friends computer right now so hopefully I wrote down all the information you will need to help me understand the problem. Here is the code I'm using, it should be easy enough to understand.

Code: Select all

<?php
// Set the db parameters
$dbPath = "myDatabase.db";
$dbType = "db3";
 
function CreateDatabase($thePath, $theType)
{
    $db = dba_open($thePath, "c", $theType);
    if(!$db)
    {
        printf("Could not create the database");
        return 0;
    }
    
    return $db;
}
 
function OpenDatabase($thePath, $theType)
{
    $db = dba_open($thePath, "r", $theType);
    if (!$db)
    {
        printf("Could not open the database");
        return 0;
    }
    
    return $db;
}
 
// Open the database, if it isn't there, create it.
$db = OpenDatabase($dbPath, $dbType);
if(!$db)
{
    $db = CreateDatabase($dbPath, $dbType);
    if(!$db)
    {
        exit;
    }
}
 
?>
Here is the error I'm getting.

Code: Select all

error:
Warning: dba_open(myDatabase.db,r) [function.dba-open]: Driver initialization failed for handler: db3: Permission denied in C:\wamp\www\DBAtest\DBAtest.php on line 20
Could not open the database
Warning: dba_open(myDatabase.db,c) [function.dba-open]: Driver initialization failed for handler: db3: Permission denied in C:\wamp\www\DBAtest\DBAtest.php on line 8
Could not create the database
The error tells me that I'm having permission problems but when I open up PHPmyadmin and go into the Privileges tab it says that the user root on local host has all privileges. The weird thing is that the file myDatabase.db is actually created in the directory but I'm getting these errors. I wanted to test and make sure that I would actually read and write files so I dug through the PHP manual a bit and played with fopen and it works just fine.

I asked this on the WAMP forums and all I was told is to use sqlitemanager to open the database. Well I go into sqlitemanager and there is an option for version and I can select 2 or 3, 3 is grayed out. I'm assuming 3 is that one I want for DB3 but I could be wrong, I'm still learning about this. I looked through PHPinfo and under the section for DBA, DB3 is listed. I'm not sure what I'm doing wrong and I'm at a loss for where I should be looking.

Any help you could give would be greatly appreciated. I should note that this is my first post here, I hope I used the tags correctly.

-Gunder
Post Reply