Welcome Guest, Not a member yet? Register   Sign In
PDO php class SQLite problem
#1

[eluser]René Tuin[/eluser]
Hi all,

I have the following problem.
I have a update functie which I build in php, only I get the following error.

'SQLSTATE[HY000] [14] unable to open database file'

Here is my code:

Code:
<?php
try {
    /*** connect to SQLite database ***/
    $db = new PDO('sqlite:http://localhost/IRS/CMS_Codeignitor/website.sqlite');
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $error = $db->errorInfo();
      
      if($error[0] != "") {
          print "<p>DATABASE CONNECTION ERROR:</p>";
          print_r($error);
      }

    foreach ($_GET['listItem'] as $position => $item) {
                        
        $sql = "UPDATE Pages SET Volgorde = $position WHERE id_Pages = $item";
        $db->exec($sql);
    }
    
    
}
catch(PDOException $e)
{
    echo $e->getMessage();
    
}
?&gt;

I can build this update functie with the framework because I call this functie with AJAX HTTP Request.
So I must build it with php.

So i hope someone can help me.
#2

[eluser]xwero[/eluser]
use a file path instead of an url
#3

[eluser]René Tuin[/eluser]
If I do that I get the following error

'SQLSTATE[HY000]: General error: 26 file is encrypted or is not a database'

The strange thing is that Codeigniter successful opened the file , but my php script not.
#4

[eluser]Sanity11[/eluser]
Anybody? I am having the same type of problems here.
#5

[eluser]TheFuzzy0ne[/eluser]
I'm wondering if the file has been written by an older/newer version of SQLite, and is not compatible with the version you're trying to use it with. I'd suggest dumping the data with the version of SQLite that works, and reimporting it using the new version.
#6

[eluser]René Tuin[/eluser]
My database file is a version 2 database.
#7

[eluser]TheFuzzy0ne[/eluser]
And what version of SQLite are you running? You can find out what PDO drivers are installed by running:
Code:
phpinfo();

Also, you seem to be accessing a URL and not a local file.
#8

[eluser]René Tuin[/eluser]
I have attach my phpinfo file as a screenshot.
I already have change my pad, but i still get that error.
#9

[eluser]TheFuzzy0ne[/eluser]
You need to be able to include the file. If you can include it, then you know the path is correct. It's probably best to use the APPPATH constant in the path, also.
#10

[eluser]René Tuin[/eluser]
I have fix it.
I use the follow code.

Code:
&lt;?php

$db = sqlite_open("../../../../website.sqlite");

foreach ($_GET['listItem'] as $position => $item) {
sqlite_query($db, "UPDATE Pages SET Volgorde = $position WHERE id_Pages = $item");
}

?&gt;

It was all about the version i use.
Thx for your help anyway.

Greetz




Theme © iAndrew 2016 - Forum software by © MyBB