Re: [PHP-DB] sqlite

2011-11-30 Thread Tamara Temple
David McGlone da...@dmcentral.net wrote:
 On Tue, 2011-11-29 at 16:31 -0600, Tamara Temple wrote:
  David McGlone da...@dmcentral.net wrote:
   places.sqlite is mozilla's bookmarks db and I was trying to read this
   db, but so far I've been unsuccessful.
   
   sqlite ver: 2.8.17
   PHP version: PHP 5.3.3-1ubuntu9.6 with Suhosin-Patch
   php5-sqlite: 5.3.3-1ubuntu9.6
  
  Okay, first off, mozilla uses sqlite3, not sqlite2, so you need to use
  those functions/classes instead.
 
 Thank you Tamara.. I'll see what I can accomplish. I'm thinking even if
 I do it this way, I'll still have to restart firefox for the page to
 update.

That I do not know. I would have assumed since they are using sqlite3,
that they would do an update whenever a bookmark was saved, but that may
not be be a valid assumption.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] sqlite

2011-11-29 Thread Tamara Temple
David McGlone da...@dmcentral.net wrote:
 places.sqlite is mozilla's bookmarks db and I was trying to read this
 db, but so far I've been unsuccessful.
 
 sqlite ver: 2.8.17
 PHP version: PHP 5.3.3-1ubuntu9.6 with Suhosin-Patch
 php5-sqlite: 5.3.3-1ubuntu9.6

Okay, first off, mozilla uses sqlite3, not sqlite2, so you need to use
those functions/classes instead.

 try
 {
   //create or open the database
   $database = new SQLiteDatabase('places.sqlite', 0666, $error);
 }
 catch(Exception $e)
 {
   die($error);
 }
 
 $query = SELECT * FROM moz_bookmarks;
 
 if($result = $database-query($query, SQLITE_BOTH, $error))
 {
   while($row = $result-fetch())
   {
 echo (ID: {$row['id']} br / );
   }
 }
 else
 {
   die($error);
 }
 

Using SQLite3, this works, dumping the first record:

?php
$db = new SQLite3('places.sqlite');
$result = $db-query(select * from moz_bookmarks);
var_dump($result-fetchArray());

 But if I use this code:
 
 try 
 {
 /*** connect to SQLite database ***/
 
 $dbh = new PDO(sqlite:places.sqlite);
 echo Handle has been created .. brbr;
 
 
 }
 catch(PDOException $e)
 {
 echo $e-getMessage();
 echo brbrDatabase -- NOT -- loaded successfully .. ;
 die( brbrQuery Closed !!! $error);
 }
 
 echo Database loaded successfully ;
 
 I get the expected output, but can't figure out how to change the above
 script to echo the contents of the DB. I just get the two messages and
 that's it.

This works as it does because PDO uses SQLite3.

Read http://us.php.net/manual/en/book.pdo.php thoroughly.

To submit a query using PDO, it's just:

$result = $dbh-query('select * from moz_bookmarks');

which returns an object of PDOStatement class in $result. Then you can
just loop on $result-fetch() to deal with each row.

This is a PDO version of the above:

try {
  $db = new PDO('sqlite:places.sqlite');
}
catch (PDOException $e) {
  die(SQLite connection failed .$e-getMessage());
}

if ($result = $db-query(select * from moz_bookmarks)) {
  var_dump($result-fetch());
} else {
  die(Query failed.);
}

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] sqlite

2011-11-29 Thread David McGlone
On Tue, 2011-11-29 at 16:31 -0600, Tamara Temple wrote:
 David McGlone da...@dmcentral.net wrote:
  places.sqlite is mozilla's bookmarks db and I was trying to read this
  db, but so far I've been unsuccessful.
  
  sqlite ver: 2.8.17
  PHP version: PHP 5.3.3-1ubuntu9.6 with Suhosin-Patch
  php5-sqlite: 5.3.3-1ubuntu9.6
 
 Okay, first off, mozilla uses sqlite3, not sqlite2, so you need to use
 those functions/classes instead.

Thank you Tamara.. I'll see what I can accomplish. I'm thinking even if
I do it this way, I'll still have to restart firefox for the page to
update.

-- 
Thanks,
David M.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] sqlite

2011-11-28 Thread David McGlone
Hi everyone, I've never fooled with sqlite before and I'm trying to do a
simple query on an sqlite db, but I don't seem to be doing anything
correct. I can't figure out how to just simply open a db file in the
directory and query it and echo back the contents. Here's some code I've
been messing with trying to accomplish this but I get a blank screen.

places.sqlite is mozilla's bookmarks db and I was trying to read this
db, but so far I've been unsuccessful.

sqlite ver: 2.8.17
PHP version: PHP 5.3.3-1ubuntu9.6 with Suhosin-Patch
php5-sqlite: 5.3.3-1ubuntu9.6

try
{
  //create or open the database
  $database = new SQLiteDatabase('places.sqlite', 0666, $error);
}
catch(Exception $e)
{
  die($error);
}

$query = SELECT * FROM moz_bookmarks;

if($result = $database-query($query, SQLITE_BOTH, $error))
{
  while($row = $result-fetch())
  {
echo (ID: {$row['id']} br / );
  }
}
else
{
  die($error);
}

But if I use this code:

try 
{
/*** connect to SQLite database ***/

$dbh = new PDO(sqlite:places.sqlite);
echo Handle has been created .. brbr;


}
catch(PDOException $e)
{
echo $e-getMessage();
echo brbrDatabase -- NOT -- loaded successfully .. ;
die( brbrQuery Closed !!! $error);
}

echo Database loaded successfully ;

I get the expected output, but can't figure out how to change the above
script to echo the contents of the DB. I just get the two messages and
that's it.
 
-- 
Thanks,
David M.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Sqlite inserts inside a PDO fetch loop

2010-05-28 Thread Brandon

Hello,

I have a situation where I am trying to create an index of words  
contained in a particular table.  The table is about 9,400 rows, and  
the index ends up being 1,500,000 words (rows).  While creating the  
index, I do a select of the table, and extract the words.  I cache  
these word results into an array, and use that array for a prepared  
insert statement into the word index table.


My problem is memory.  It maxes out at about 35 MB.  This is a bit  
high, and what I would like to do is do an onset transaction when the  
array reaches a certain size, like 10,000, then unset the array and  
continue.  The problem with that is I cannot commit the insert while  
the fetch statement is still pending.


I have tried fetchAll instead, but still have similar memory issues.

I have also tried to commit the inserts at the end, but that causes  
Sqlite to hog the memory.


Is there any way to fix this, or is this just the cost of doing  
business with Sqlite?


Thanks!

B



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite inserts inside a PDO fetch loop

2010-05-28 Thread Phpster
Can't you do a limit in the extract SQL and mark the records extracted  
so that you don't end up extraxting the same ones?




Bastien

Sent from my iPod

On May 28, 2010, at 5:49 PM, Brandon version...@gmail.com wrote:


Hello,

I have a situation where I am trying to create an index of words  
contained in a particular table.  The table is about 9,400 rows, and  
the index ends up being 1,500,000 words (rows).  While creating the  
index, I do a select of the table, and extract the words.  I cache  
these word results into an array, and use that array for a prepared  
insert statement into the word index table.


My problem is memory.  It maxes out at about 35 MB.  This is a bit  
high, and what I would like to do is do an onset transaction when  
the array reaches a certain size, like 10,000, then unset the array  
and continue.  The problem with that is I cannot commit the insert  
while the fetch statement is still pending.


I have tried fetchAll instead, but still have similar memory issues.

I have also tried to commit the inserts at the end, but that causes  
Sqlite to hog the memory.


Is there any way to fix this, or is this just the cost of doing  
business with Sqlite?


Thanks!

B



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

Hi,

I'm not very experienced in PHP, and have always used mysql with it,  
but now I have a Sqlite database that I want to manipulate and I  
thought PHP would be an easy way to do it. It turned out that I need  
to use PDO to access a Sqlite V3 database, which is all new to me.


I've managed to connect to my database, and run a select query, but  
now I need to run an UPDATE query and it just doesn't seem to take  
effect. Here's the code I'm using, I've tried all sorts of  
combinations, prepare, execute, query, but when I go back into the db  
it hasn't updated the rows.



[code]

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;


$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

$sesdb-exec($sql);

}

[/code]

When  I re-run the select query, the ZQuantity is still as it was  
before. I've tried echoing out the query and running it on the db  
directly and that seems fine.


This isn't issuing any error messages either, it's just continuig with  
the next code (SELECT query again to check the db contents)


Can anyone help me?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;


$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
can you put
error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] wrote:
 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;

 $statement= $sesdb-query($query);
 $result=$statement-fetchAll();

 foreach ($result as $product) {
 $prodname=$product[0];
 $prodqty = $product[1];
 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;


$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}
On 20 Aug 2008, at 10:11, Evert Lammerts wrote:


can you put
error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

It's still not working :(

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;


$statement= $sesdb-query($query);
$result=$statement-fetchAll();
$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
$sesdb-exec($sql);


On 20 Aug 2008, at 11:10, Evert Lammerts wrote:


A little time on google told me that if you want to do a write after a
read (or the other way around) you need to free up the query resource
- apparently they hold read / write locks.

so, free up $statement before doing a write:

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;


$statement= $sesdb-query($query);
$result=$statement-fetchAll();

$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

$sesdb-exec($sql);

}


On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}
On 20 Aug 2008, at 10:11, Evert Lammerts wrote:


can you put
error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 


wrote:


still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE  
ZPRODUCTID={$prodid};


Evert

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php








Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
Sorry, I'm out of options. Hopefully somebody on the list has a little
more experience with PDO.

On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 It's still not working :(
 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;
 $statement= $sesdb-query($query);
 $result=$statement-fetchAll();
 $statement=null;
 foreach ($result as $product) {
 $prodname=$product[0];
 $prodqty = $product[1];
 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a
 read (or the other way around) you need to free up the query resource
 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;

 $statement= $sesdb-query($query);
 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {
 $prodname=$product[0];
 $prodqty = $product[1];
 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

Thanks for trying,

On 20 Aug 2008, at 11:42, Evert Lammerts wrote:


Sorry, I'm out of options. Hopefully somebody on the list has a little
more experience with PDO.

On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

It's still not working :(
$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;
$statement= $sesdb-query($query);
$result=$statement-fetchAll();
$statement=null;
foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
$sesdb-exec($sql);

On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

A little time on google told me that if you want to do a write  
after a

read (or the other way around) you need to free up the query resource
- apparently they hold read / write locks.

so, free up $statement before doing a write:

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

$sesdb-exec($sql);

}


On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED] 


wrote:

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

can you put

error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 



wrote:

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php








--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
What happens if you try the UPDATE before a SELECT?

$sesdb = new PDO('sqlite:file.sqlite3');
var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1));

On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
[EMAIL PROTECTED] wrote:
 Sorry, I'm out of options. Hopefully somebody on the list has a little
 more experience with PDO.

 On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 It's still not working :(
 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;
 $statement= $sesdb-query($query);
 $result=$statement-fetchAll();
 $statement=null;
 foreach ($result as $product) {
 $prodname=$product[0];
 $prodqty = $product[1];
 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a
 read (or the other way around) you need to free up the query resource
 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;

 $statement= $sesdb-query($query);
 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {
 $prodname=$product[0];
 $prodqty = $product[1];
 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php







-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs

It still doesn't run the update, but the var_dump displays
bool(false) bool(false)

$sesdb = new PDO('sqlite:wtc.sqlite3');

$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=bli-343;
var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE  
ZPRODUCTID=bli-343));


$sesdb-exec($sql);

var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE  
ZPRODUCTID=bli-343));


$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory != 14;




On 20 Aug 2008, at 11:45, Evert Lammerts wrote:


What happens if you try the UPDATE before a SELECT?

$sesdb = new PDO('sqlite:file.sqlite3');
var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE  
ZPRODUCTID=1));


On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
[EMAIL PROTECTED] wrote:
Sorry, I'm out of options. Hopefully somebody on the list has a  
little

more experience with PDO.

On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

It's still not working :(
$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;
$statement= $sesdb-query($query);
$result=$statement-fetchAll();
$statement=null;
foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
$sesdb-exec($sql);

On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

A little time on google told me that if you want to do a write  
after a
read (or the other way around) you need to free up the query  
resource

- apparently they hold read / write locks.

so, free up $statement before doing a write:

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE  
ZPRODUCTID='{$prodid}';


$sesdb-exec($sql);

}


On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED] 


wrote:

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

can you put

error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 



wrote:

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php











Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
Alright, getting somewhere.

Try this:

$sesdb = new PDO('sqlite:wtc.sqlite3');
if ($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE
ZPRODUCTID='bli-343') === false) {
echo $sesdb-errorInfo();
}

Don't forget the quotes around the product id (it's a string so you
need them after all)


On Wed, Aug 20, 2008 at 12:50 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 It still doesn't run the update, but the var_dump displays
 bool(false) bool(false)
 $sesdb = new PDO('sqlite:wtc.sqlite3');
 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=bli-343;
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE
 ZPRODUCTID=bli-343));
 $sesdb-exec($sql);
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE
 ZPRODUCTID=bli-343));
 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=
 14;


 On 20 Aug 2008, at 11:45, Evert Lammerts wrote:

 What happens if you try the UPDATE before a SELECT?

 $sesdb = new PDO('sqlite:file.sqlite3');
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1));

 On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
 [EMAIL PROTECTED] wrote:

 Sorry, I'm out of options. Hopefully somebody on the list has a little

 more experience with PDO.

 On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 It's still not working :(

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a

 read (or the other way around) you need to free up the query resource

 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php









-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs
OK, I found one problem, the database file was not writeable, I added  
this code to find the error:


$sesdb-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

However, I now get the following error:
Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General  
error: 14 unable to open database file in/home/amy2203/public_html/ 
willowtreecrafts/seweblink/seinvaudit.php on lin


Sorry to have such a basic problem!

On 20 Aug 2008, at 11:45, Evert Lammerts wrote:


What happens if you try the UPDATE before a SELECT?

$sesdb = new PDO('sqlite:file.sqlite3');
var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE  
ZPRODUCTID=1));


On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
[EMAIL PROTECTED] wrote:
Sorry, I'm out of options. Hopefully somebody on the list has a  
little

more experience with PDO.

On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

It's still not working :(
$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;
$statement= $sesdb-query($query);
$result=$statement-fetchAll();
$statement=null;
foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
$sesdb-exec($sql);

On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

A little time on google told me that if you want to do a write  
after a
read (or the other way around) you need to free up the query  
resource

- apparently they hold read / write locks.

so, free up $statement before doing a write:

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE  
ZPRODUCTID='{$prodid}';


$sesdb-exec($sql);

}


On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED] 


wrote:

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

can you put

error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 



wrote:

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php









--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
It seems you've figured it out. I think you only need to chmod the DB
directory and you're good to go.

On Wed, Aug 20, 2008 at 1:04 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 OK, I found one problem, the database file was not writeable, I added this
 code to find the error:
 $sesdb-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 However, I now get the following error:
 Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General error: 14
 unable to open database file
 in/home/amy2203/public_html/willowtreecrafts/seweblink/seinvaudit.php on lin
 Sorry to have such a basic problem!
 On 20 Aug 2008, at 11:45, Evert Lammerts wrote:

 What happens if you try the UPDATE before a SELECT?

 $sesdb = new PDO('sqlite:file.sqlite3');
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1));

 On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
 [EMAIL PROTECTED] wrote:

 Sorry, I'm out of options. Hopefully somebody on the list has a little

 more experience with PDO.

 On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 It's still not working :(

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a

 read (or the other way around) you need to free up the query resource

 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php







 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Amy Gibbs
OK, I found one problem, the database file was not writeable, I added  
this code to find the error:


$sesdb-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);

then I got the following error:
Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General  
error: 14 unable to open database file in/home/amy2203/public_html/ 
willowtreecrafts/seweblink/seinvaudit.php on lin


which was a permissions error on the folder,

now i'm timing out and getting nothing,

Sorry to have such a basic problem!

On 20 Aug 2008, at 11:45, Evert Lammerts wrote:


What happens if you try the UPDATE before a SELECT?

$sesdb = new PDO('sqlite:file.sqlite3');
var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE  
ZPRODUCTID=1));


On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
[EMAIL PROTECTED] wrote:
Sorry, I'm out of options. Hopefully somebody on the list has a  
little

more experience with PDO.

On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED] 
 wrote:

It's still not working :(
$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;
$statement= $sesdb-query($query);
$result=$statement-fetchAll();
$statement=null;
foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};
$sesdb-exec($sql);

On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

A little time on google told me that if you want to do a write  
after a
read (or the other way around) you need to free up the query  
resource

- apparently they hold read / write locks.

so, free up $statement before doing a write:

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=

14;

$statement= $sesdb-query($query);
$result=$statement-fetchAll();

$statement=null;

foreach ($result as $product) {
$prodname=$product[0];
$prodqty = $product[1];
$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE  
ZPRODUCTID='{$prodid}';


$sesdb-exec($sql);

}


On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED] 


wrote:

No errors reported, but it's not updating the db,

error_reporting(E_ALL);

$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];


$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

can you put

error_reporting(E_ALL);

somewhere above the query and check if there's some output?

On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED] 



wrote:

still not working,


$sesdb = new PDO('sqlite:file.sqlite3');

$query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE  
ZCategory !=


14;

$statement= $sesdb-query($query);

$result=$statement-fetchAll();

foreach ($result as $product) {

$prodname=$product[0];

$prodqty = $product[1];

$prodid=$product[2];

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

$sesdb-exec($sql);

}

On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='. 
$prodid.';


Try to unquote $prodid:

$sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

Evert

--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



--

PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php









--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
Can you post the code you're using when you get the timeout?

I guess you already tried to do a select only and an update only to
check if it works?

On Wed, Aug 20, 2008 at 1:11 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 OK, I found one problem, the database file was not writeable, I added this
 code to find the error:
 $sesdb-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 then I got the following error:
 Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General error: 14
 unable to open database file
 in/home/amy2203/public_html/willowtreecrafts/seweblink/seinvaudit.php on lin
 which was a permissions error on the folder,
 now i'm timing out and getting nothing,
 Sorry to have such a basic problem!
 On 20 Aug 2008, at 11:45, Evert Lammerts wrote:

 What happens if you try the UPDATE before a SELECT?

 $sesdb = new PDO('sqlite:file.sqlite3');
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1));

 On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
 [EMAIL PROTECTED] wrote:

 Sorry, I'm out of options. Hopefully somebody on the list has a little

 more experience with PDO.

 On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 It's still not working :(

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a

 read (or the other way around) you need to free up the query resource

 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php







 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Sqlite 3 pdo update query problem

2008-08-20 Thread Evert Lammerts
Forget my last mail. Good to hear it's solved.

On Wed, Aug 20, 2008 at 1:20 PM, Evert Lammerts
[EMAIL PROTECTED] wrote:
 Can you post the code you're using when you get the timeout?

 I guess you already tried to do a select only and an update only to
 check if it works?

 On Wed, Aug 20, 2008 at 1:11 PM, Amy Gibbs [EMAIL PROTECTED] wrote:
 OK, I found one problem, the database file was not writeable, I added this
 code to find the error:
 $sesdb-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 then I got the following error:
 Warning: PDO::exec() [function.PDO-exec]: SQLSTATE[HY000]: General error: 14
 unable to open database file
 in/home/amy2203/public_html/willowtreecrafts/seweblink/seinvaudit.php on lin
 which was a permissions error on the folder,
 now i'm timing out and getting nothing,
 Sorry to have such a basic problem!
 On 20 Aug 2008, at 11:45, Evert Lammerts wrote:

 What happens if you try the UPDATE before a SELECT?

 $sesdb = new PDO('sqlite:file.sqlite3');
 var_dump($sesdb-exec(UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID=1));

 On Wed, Aug 20, 2008 at 12:42 PM, Evert Lammerts
 [EMAIL PROTECTED] wrote:

 Sorry, I'm out of options. Hopefully somebody on the list has a little

 more experience with PDO.

 On Wed, Aug 20, 2008 at 12:26 PM, Amy Gibbs [EMAIL PROTECTED]
 wrote:

 It's still not working :(

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY=0 WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 On 20 Aug 2008, at 11:10, Evert Lammerts wrote:

 A little time on google told me that if you want to do a write after a

 read (or the other way around) you need to free up the query resource

 - apparently they hold read / write locks.

 so, free up $statement before doing a write:

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 $statement=null;

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='{$prodid}';

 $sesdb-exec($sql);

 }


 On Wed, Aug 20, 2008 at 11:49 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 No errors reported, but it's not updating the db,

 error_reporting(E_ALL);

 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];


 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 10:11, Evert Lammerts wrote:

 can you put

 error_reporting(E_ALL);

 somewhere above the query and check if there's some output?

 On Wed, Aug 20, 2008 at 11:02 AM, Amy Gibbs [EMAIL PROTECTED]

 wrote:

 still not working,


 $sesdb = new PDO('sqlite:file.sqlite3');

 $query=SELECT ZNAME, ZQUANTITY, ZPRODUCTID FROM ZITEM WHERE ZCategory !=

 14;

 $statement= $sesdb-query($query);

 $result=$statement-fetchAll();

 foreach ($result as $product) {

 $prodname=$product[0];

 $prodqty = $product[1];

 $prodid=$product[2];

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 $sesdb-exec($sql);

 }

 On 20 Aug 2008, at 09:59, Evert Lammerts wrote:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID='.$prodid.';

 Try to unquote $prodid:

 $sql = UPDATE ZITEM SET ZQUANTITY='0' WHERE ZPRODUCTID={$prodid};

 Evert

 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php



 --

 PHP Database Mailing List (http://www.php.net/)

 To unsubscribe, visit: http://www.php.net/unsub.php







 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SQLite 3.0 extension for PHP

2005-04-14 Thread Hendy Irawan
Hi

Is there an SQLite 3.0 extension for PHP?

The one that's bundled with PHP 5.0.4 is SQLite 2. Also the same thing
with the PECL package at http://pecl.php.net/package/SQLite

Thanks a lot!
-- 
Hendy Irawan
http://www.gauldong.net
http://dev.gauldong.net

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] sqlite access causes signal 11

2005-02-04 Thread Sven Oliver Moll
Hello,
I'm using Serendipity (http://www.s9y.org), a blog system. Running it with
an sqlite backend, it crashes the apache instance with a signal 11. After
some analysing I can tell that the crash is processing an sqlite_query()
statement.
I created a small testcase that crashes with 5.0.3, 5.0.x-cvs and 5.1.x-cvs.
If there are any more questions please feel free to contact me.
Greetings from Germany,
SvOlli
--
|  ___   |
| (  /\  | We can't afford to be innocent, stand up and face the enemy
|__)v\/lli a.k.a.| It's a do or die situation, we will be invincible
|Sven Oliver Moll|   -- Pat Benatar, Invincible
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] sqlite access causes signal 11

2005-02-04 Thread Sven Oliver Moll
On Fri, 4 Feb 2005, Sven Oliver Moll wrote:
Hello,
I'm using Serendipity (http://www.s9y.org), a blog system. Running it with
an sqlite backend, it crashes the apache instance with a signal 11. After
some analysing I can tell that the crash is processing an sqlite_query()
statement.
I created a small testcase that crashes with 5.0.3, 5.0.x-cvs and 5.1.x-cvs.
If there are any more questions please feel free to contact me.
After a nice debugging session I found out that the crash happens inside
the sqlite database itself. The bug is fixed in sqlite 2.8.15. I simply
replaced all files from ext/sqlite/libsqlite/src with their versions from
the sqlite 2.8.15 distribution. Now it works like a charm.
Greetings from Germany and singing off into the weekend!
Winke: o/~
SvOlli
--
|  ___   |
| (  /\  | For once, Microsoft wasn't exagerating when they named
|__)v\/lli a.k.a.| it the Jet Engine - your data's the seagull.
|Sven Oliver Moll|   -- Chris Adams
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQLite problem INSERTing string

2004-09-19 Thread Stefan Reimers
Hello,
I am currently experiencing a problem with an INSERT statement in SQLite.
First of all an excerpt from the code:
$val = 127.0.0.1;
$query = INSERT INTO node (uri,name) VALUES (.$val.,'bla');
$db_name = mysqlite;
if($db_hdl = sqlite_open($db_name)){

$db_result = sqlite_query($db_hdl,$query);

}
I get the error message:
Warning: sqlite_query(): near .: syntax error in 
C:\Programme\xampp\htdocs\dipl\testclient\sqlite_test.php on line 10

I tried addslashes (which I know I shouldn't), sqlite_escape_string, any 
variant of quotes etc, I asked google and the searched the news groups 
but with no relevant result, except the insight, that others experience 
the same so long unsolved problem or use a syntax in their tutorials 
that does not work with my code...

As you an see from the error message, I use Windows, Apache, PHP4 with 
SQLite in a 2.8.14 version.

If anyone has a clue, please contact me or just answer.
Thanks in advance
Stefan
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] SQLite problem INSERTing string

2004-09-19 Thread Darryl

$val = 127.0.0.1;
$query = INSERT INTO node (uri,name) VALUES ('.$val.','bla');

Try that?
-Original Message-
From: Stefan Reimers [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 19, 2004 6:37 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] SQLite problem INSERTing string

Hello,

I am currently experiencing a problem with an INSERT statement in SQLite.

First of all an excerpt from the code:

$val = 127.0.0.1;
$query = INSERT INTO node (uri,name) VALUES (.$val.,'bla');

$db_name = mysqlite;

if($db_hdl = sqlite_open($db_name)){

$db_result = sqlite_query($db_hdl,$query);

}

I get the error message:

Warning: sqlite_query(): near .: syntax error in 
C:\Programme\xampp\htdocs\dipl\testclient\sqlite_test.php on line 10

I tried addslashes (which I know I shouldn't), sqlite_escape_string, any 
variant of quotes etc, I asked google and the searched the news groups 
but with no relevant result, except the insight, that others experience 
the same so long unsolved problem or use a syntax in their tutorials 
that does not work with my code...

As you an see from the error message, I use Windows, Apache, PHP4 with 
SQLite in a 2.8.14 version.

If anyone has a clue, please contact me or just answer.
Thanks in advance
Stefan

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] SQLite problem INSERTing string

2004-09-19 Thread M Saleh EG
$val=127.0.0.1;
$query=INSERT INTO node set uri=\$val\, name=\bla\;

Try this one... think is better n less confusing for u...

On Sun, 19 Sep 2004 19:13:48 +0200, Darryl [EMAIL PROTECTED] wrote:
 
 $val = 127.0.0.1;
 $query = INSERT INTO node (uri,name) VALUES ('.$val.','bla');
 
 Try that?
 
 
 -Original Message-
 From: Stefan Reimers [mailto:[EMAIL PROTECTED]
 Sent: Sunday, September 19, 2004 6:37 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] SQLite problem INSERTing string
 
 Hello,
 
 I am currently experiencing a problem with an INSERT statement in SQLite.
 
 First of all an excerpt from the code:
 
 $val = 127.0.0.1;
 $query = INSERT INTO node (uri,name) VALUES (.$val.,'bla');
 
 $db_name = mysqlite;
 
 if($db_hdl = sqlite_open($db_name)){
 
$db_result = sqlite_query($db_hdl,$query);
 
 }
 
 I get the error message:
 
 Warning: sqlite_query(): near .: syntax error in
 C:\Programme\xampp\htdocs\dipl\testclient\sqlite_test.php on line 10
 
 I tried addslashes (which I know I shouldn't), sqlite_escape_string, any
 variant of quotes etc, I asked google and the searched the news groups
 but with no relevant result, except the insight, that others experience
 the same so long unsolved problem or use a syntax in their tutorials
 that does not work with my code...
 
 As you an see from the error message, I use Windows, Apache, PHP4 with
 SQLite in a 2.8.14 version.
 
 If anyone has a clue, please contact me or just answer.
 Thanks in advance
 Stefan
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] SQLite security

2004-08-21 Thread Ed Lazor
 Shared hosting vulnerabilities have nothing to do with SQLite security.
 phpMyAdmin seems to be a popular choice for MySQL admin and I reckon
 there must be a few people who use it in shared hosting situations.

Most of the shared hosting options I've seen lately list phpMyAdmin as one
of the benefits of going with their service...

-Ed

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] SQLite security

2004-08-20 Thread Adam Q
You can use Mcrypt, OpenSSL or any other crypographic provider to 
encrypt
the information however for your application to be able to access the
information you would also have to store the encryption key, reducing 
the
protection offered.
Any PHP MySQL connection script has the DB password in it somewhere so 
this is not an issue I think.
phpMyAdmin allows you to put the password into a config file...
But you can't download a MySQL database by typing in a URL.

I think encryption for SQLite is essential for PHP. It makes it almost 
useless in a webscripting language.
Suppose you wanted to create an open source, easily portable, file 
based guestbook in PHP. I would never use SQLLite under the current 
circumstances... Although I would love to. It seems like the perfect 
solution.

But the database needs a password otherwise it is just too much of 
a security risk.

SQLite is intended for applications that need a database but don't 
need a
full fledged solution such as PostgreSQL
I can't think of one (1) web based application where I would recommend 
SQLite - if I can't specify a password for access.
Maybe for PHP-GTK, but that is not web based (and PHP is used a great 
deal for web scripting).

Remember regardless of the database you use if you are using a shared
hosting provider it is possible othere hosting clients will be able to
access your database regardless of the engine you use.
Shared hosting vulnerabilities have nothing to do with SQLite security.
phpMyAdmin seems to be a popular choice for MySQL admin and I reckon 
there must be a few people who use it in shared hosting situations.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQLite security

2004-08-16 Thread Adam Q
I would like to use an SQLite DB for the prefs for an open source PHP 
project, but I can't find any way to be sure the DB file is going to be 
secure... Is it possible to encrypt a SQLite DB file?

With the current setup, if I include a .htaccess for the DB dir, this 
will only work for Apache - not IIS.
I know I can include a warning about how important it is to place the 
files outside the HTTP directory tree and .htaccess files are good, but 
it is just too easy to download an SQLite DB... I can't really see any 
PHP use that would be OK for this really.
if I put the db file SQLITE.DB into /www/db
Anybody can d/l it by typing
http://myserver.com/db/SQLITE.DB

I though I might even be able to prevent d/l by naming the DB file with 
a . at the start but it makes do difference.

... and if the project is open source it is just too much of a security 
risk as everybody knows where the file is going to be on a default 
installation.

Otherwise I'm stuck with the standard PHP prefs file confing.inc.php 
(- which is safe from prying eyes):
?
if (defined(correct_entry_point)) {
my_pref[1] = lots of good stuff;
}
?

But updating this on pref changes is no fun compared to SQLite
shrug
Please somebody tell me I'm wrong,
Cheers,
Adam
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] SQLite security

2004-08-16 Thread Jason Sheets
SQLite security is based primarily on filesystem security, placing the
database outside the web root (i.e. /home/user/private/SQLITE.db instead of
/home/www/SQLITE.db) and including an option in your base configuration or
include file to point to the database file.

You can use Mcrypt, OpenSSL or any other crypographic provider to encrypt
the information however for your application to be able to access the
information you would also have to store the encryption key, reducing the
protection offered.

If I were you I'd follow the first approach, in my opinion the second
approach's overhead does not justify the minimal security gained.

SQLite is intended for applications that need a database but don't need a
full fledged solution such as PostgreSQL.

Remember regardless of the database you use if you are using a shared
hosting provider it is possible othere hosting clients will be able to
access your database regardless of the engine you use.

Jason

-Original Message-
From: Adam Q [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 16, 2004 7:34 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] SQLite security

I would like to use an SQLite DB for the prefs for an open source PHP
project, but I can't find any way to be sure the DB file is going to be
secure... Is it possible to encrypt a SQLite DB file?

With the current setup, if I include a .htaccess for the DB dir, this will
only work for Apache - not IIS.
I know I can include a warning about how important it is to place the files
outside the HTTP directory tree and .htaccess files are good, but it is just
too easy to download an SQLite DB... I can't really see any PHP use that
would be OK for this really.
if I put the db file SQLITE.DB into /www/db Anybody can d/l it by typing
http://myserver.com/db/SQLITE.DB

I though I might even be able to prevent d/l by naming the DB file with a
. at the start but it makes do difference.

... and if the project is open source it is just too much of a security risk
as everybody knows where the file is going to be on a default installation.

Otherwise I'm stuck with the standard PHP prefs file confing.inc.php 
(- which is safe from prying eyes):
?
if (defined(correct_entry_point)) {
my_pref[1] = lots of good stuff;
}
?

But updating this on pref changes is no fun compared to SQLite

shrug

Please somebody tell me I'm wrong,
Cheers,
Adam

--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] sqlite and php4

2004-06-02 Thread Ivan Voras
I recently read the changelog (NEWS) file pointed by the announcment for 
4.3.7rc1 on the web and came across this line:

- Fixed bug #28112 (sqlite_query() crashing apache on malformed query). 
(Ilia, Marcus)

Does that mean sqlite is/will be in 4.3.7? (I'm only asking for a 
clarification :) )

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQLite and PHP4

2004-05-18 Thread Eli White
After playing around some with SQLite with PHP5, I decided that I wanted 
to have it working in PHP4 to start using it fully while waiting for 
PHP5 to come out.

However, I ran into a snag ... after downloading 
it/phpizeing/configure/make/makeinstall ... I added the 
extension=sqlite.so line to my server (Apache 1.3.31, Solaris) ... 
rebooted, and nothing happened.

My phpinfo page doesn't mention any sqlite support being added, I don't 
see any errors in Apache's error log, and any test scripts I write to 
use sqlite_open claim the function doesn't exist.

What have I missed here?
Thanks,
Eli
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] [Attn] Re: [PHP-DB] SQLite behaving bad?

2004-02-18 Thread Gerard Samuel
On Tuesday 17 February 2004 04:41 pm, Gerard Samuel wrote:
 Currently using sqlite 2.8.11 (distributed by php snaps) with php4.3.5rc2
 on windows XP.
 Several months ago, I added support for sqlite in a database abstraction
 class I created.  It worked great then.
 Im trying to see if things are still ok today, and its not.
 For example executing the select query -
 select f.foo, b.bar from table f, table b where f.id = b.id;
 Should return result table fields foo and bar.
 Instead its returning result table fields f.foo and b.bar.


Just an update about this.
Due to changes in SQLite, the problem that I've described in this email, is 
now the default behaviour of SQLite.
So if you get bitten by this, its up to you to figure a way around this.


 Example script
 ?php

 // sqlite connection parameters produce $conn resource id

 $sql = 'SELECT f.foo, b.bar FROM table f, table b WHERE f.id = b.id';
 $result = sqlite_query($conn, $sql);
 if ($result === false)
 {
die('For some reason');
 }

 while($row = sqlite_fetch_array($result, SQLITE_ASSOC))
 {
 // The expected results return nothing
 var_dump($row['foo'], $row['bar']);

 // The unexpected results return data
 var_dump($row['f.foo'], $row['b.bar']);  // You get the correct values
 }

 ?

 So has anyone experienced this with the current sqlite/php combination?
 This used to work correctly with sqlite 2.8.3 (distributed by php snaps)
 Were there any notices that I may have missed over these past months??

 Thanks for any help you may provide...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SQLite?

2004-02-03 Thread alain
Is it a good place to ask questions about SQLite? I'm going to test it 
with PHP5. Anybody here has done it?
Alain

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQLite PRIMARY KEY.

2004-01-30 Thread Stuart Gilbert
I'm trying to get my PHP code to INSERT a new row and have the PRIMARY 
KEY field automatically set to the next available integer.
I read, somewhere, that if I send null as the primary key value then 
SQLite will automatically incrememnt it for me.

I've tried sending all sorts of things that I thought might work, but as 
yet I have not been able to get it right.

Can someone please help me?

Regards,
Stuart Gilbert.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] SQLite PRIMARY KEY.

2004-01-30 Thread Stuart Gilbert
Well, it appears I tried everything except JUST the word NULL.
Sorry for wasting your time.
Regards,
Stuart Gilbert.
Stuart Gilbert wrote:
I'm trying to get my PHP code to INSERT a new row and have the PRIMARY 
KEY field automatically set to the next available integer.
I read, somewhere, that if I send null as the primary key value then 
SQLite will automatically incrememnt it for me.

I've tried sending all sorts of things that I thought might work, but as 
yet I have not been able to get it right.

Can someone please help me?

Regards,
Stuart Gilbert.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQLITE

2003-11-22 Thread Bronislav Kluka
Hi, I've got questions:

I've got sqlite like PHP module (under windows). I tried this:
a)execute script 1 (selecting from some table), it tooks 2 minutes
b)execute script 2 , it tooks 3 minutes
c)execute them both at the same time (from different browser windows), both
of them stopped also at the same time and   it tooks 5 minutes

I've tried another questions and both of the scripts allways stopped at the
same time with duration of he sum of the time fo each process separated.
This is not, of course, the behaviour I would expect... Is this some feature
of sqlite or an I doing something wrong??

I've also tried the same with MySql and the result should be like
1/ first script alone - 2 minutes
2/ second script alone - 3 minutes
3/ both of them at the same time - first took 3 minutes, second took 4
minutes...



Brona

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SQLite

2003-11-20 Thread Bronislav Kluka
Hi, I was trying to work with SQLite, everything is OK, but it seems not to
vork in thread, but in sequences. I mean: I perform a question which tooks 2
minutes, then another, which tooks 3 minutes, then I perform them both from
2 separated browser windows and both of them stops at the same time and both
of them tooks 5 minutes so it looks like it do not perform the queries in
threads.
Does anybody know, what does it means???

Bronislav Klucka

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SQLite

2003-10-31 Thread JR
I am trying to get the SQLite package to work with PHP and I am failing
miserably.

I have run: pear download http://pecl.php.net/get/SQLite-1.0.tgz, no
problem here.

Then I run: pear install SQLite-1.0.tgz and get a make error of:
/tmp/tmpACnhIu/SQLite-1.0/sqlite.c:29:17: php.h: No such file or
directory
/tmp/tmpACnhIu/SQLite-1.0/sqlite.c:30:21: php_ini.h: No such file or
directory
/tmp/tmpACnhIu/SQLite-1.0/sqlite.c:31:31: ext/standard/info.h: No such
file or directory
make: *** [sqlite.lo] Error 1
`make' failed

The entire output is below. 

I am running Red Hat ES 2.1 with PHP 4.3.3. The configure statement I
used to compile PHP is below.

Thank you in advance for any advice you can provide!

JR






./configure --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share  --include
dir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info --prefix=/usr --with-config-file-path=/etc
--enable-force-cgi-redirect --disable-debug --enable-pic --dis
able-rpath --enable-inline-optimization --with-bz2 --with-db3
--with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr 
--with-gd --enable-gd-native-ttf --with-ttf --with-gdbm --with-gettext
--with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr - -with-mm
--with-openssl --with-png --with-regex=system --with-xml
--with-expat-dir=/usr --with-zlib --with-layout=GNU --enable-bcmat h
--enable-debugger --enable-exif --enable-ftp --with-pear=/usr/share/pear
--enable-magic-quotes --enable-safe-mode --enable-sockets
--enable-sysvsem --enable-sysvshm --enable-discard-path
--enable-track-vars --enable-trans-sid --enable-yp --enable-wddx
--without-
oci8 --with-mysql --enable-memory-limit --enable-bcmath --enable-shmop
--enable-versioning --enable-calendar --enable-dbx --enable-d io
--enable-mbstring --enable-mbstr-enc-trans --with-apxs=/usr/sbin/apxs
--with-sqlite=shared



[EMAIL PROTECTED] html]# pear install SQLite-1.0.tgz
48 source files, building
running: phpize
You should update your `aclocal.m4' by running aclocal. Configuring for:
  PHP Api Version:   20020918
  Zend Module Api No:   20020429
  Zend Extension Api No:   20021010
building in /var/tmp/pear-build-root/SQLite-1.0
running: /tmp/tmpACnhIu/SQLite-1.0/configure
creating cache ./config.cache
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes checking whether gcc accepts
-g... yes checking whether gcc and cc understand -c and -o together...
yes checking if compiler supports -R... no checking if compiler supports
-Wl,-rpath,... yes checking for PHP prefix... /usr checking for PHP
includes... -Idir=/usr/include/php -Idir=/usr/include/php/main
-Idir=/usr/include/php/Zend -Idir=/usr/include/php/TSRM checking for PHP
extension directory... /usr/lib/20020429 checking how to run the C
preprocessor... gcc -E checking for gawk... gawk checking for sqlite
support... yes, shared checking size of char *... 4 checking for
lemon... no checking for usleep... yes checking for nanosleep... yes
checking for time.h... yes checking for Cygwin environment... no
checking for mingw32 environment... no checking build system type...
i686-pc-linux-gnu checking for ld used by GCC... /usr/bin/ld checking if
the linker (/usr/bin/ld) is GNU ld... yes checking for /usr/bin/ld
option to reload object files... -r checking for BSD-compatible nm...
/usr/bin/nm -B checking whether ln -s works... yes checking how to
recognise dependant libraries... pass_all checking for object suffix...
o checking for executable suffix... no checking command to parse
/usr/bin/nm -B output... ok checking for dlfcn.h... yes checking for
ranlib... ranlib checking for strip... strip checking for objdir...
.libs checking for gcc option to produce PIC... -fPIC checking if gcc
PIC flag -fPIC works... yes checking if gcc static flag -static works...
yes checking if gcc supports -c -o file.o... yes checking if gcc
supports -c -o file.lo... yes checking if gcc supports -fno-rtti
-fno-exceptions... yes checking whether the linker (/usr/bin/ld)
supports shared libraries... yes checking how to hardcode library paths
into programs... immediate checking whether stripping libraries is
possible... yes checking dynamic linker characteristics... GNU/Linux
ld.so checking if libtool supports shared libraries... yes checking
whether -lc should be explicitly linked in... no creating libtool
updating cache ./config.cache creating ./config.status creating config.h
running: make
sed -e s/--VERS--/2.8.3/ -e s/--ENCODING--/ISO8859/
/tmp/tmpACnhIu/SQLite-1.0/libsqlite/src/sqlite.h.in
/tmp/tmpACnhIu/SQLite-1.0/libsqlite/src/sqlite.h
/bin/sh /var/tmp/pear-build-root/SQLite-1.0/libtool --mode=compile gcc
-I/tmp/tmpACnhIu/SQLite-1.0/libsqlite/src -I.

[PHP-DB] sqlite question

2003-09-02 Thread andu
I use the following to delete a column from a table:

$columns= 'col1','col2','col3','col4','col5';
$columns=str_replace(','.'col3','',$columns);
$this-open_db(); //get the resource number($this-c_id)
$r=sqlite_query($this-c_id,BEGIN);
$r=sqlite_query($this-c_id,CREATE TEMPORARY TABLE
'backup'($columns));
$r=sqlite_query($this-c_id,INSERT INTO 'backup'
SELECT $columns FROM '$table_name');
$r=sqlite_query($this-c_id,DROP TABLE '$table_name');
$r=sqlite_query($this-c_id,CREATE TABLE '$table_name'($columns));
$r=sqlite_query($this-c_id,INSERT
INTO'$table_name' SELECT $columns FROM 'backup');
$r=sqlite_query($this-c_id,DROP TABLE 'backup');
$r=sqlite_query($this-c_id,COMMIT);
sqlite_close($this-c_id);

What happens is that 
INSERT INTO 'backup'SELECT $columns FROM '$table_name' 
populates the 'backup' table with
the names of the columns instead of the content of the columns. If I
unquote the columns names in $columns (col1,col2,col3...) the new table
is populated with the content, which is the correct behaviour. 
Trouble is that I prefer quoting column names in case they have more
words then one.
Same problem happened with my 'add column' function but I was able to
fix that selecting *  as opposed to $columns for populating the
temp table. 
I am pretty sure this is not sqlite behavior in console.
Any help will be appreciated, thanks.
This extension is new and probably still has bugs and undocumented features but
I've used sqlite in other applications and it kicks ass, for most web applications
anything bigger is overkill.



Regards, Andu Novac

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] sqlite functions

2003-08-24 Thread andu
The function sqlite_fetch_all() mentioned in the changelog of version
1.0 of the extension is not documented in php docs.
I'd like to know what is the diference between sqlite_fetch_all() and
sqlite_array_query() about which the docs say that [it] is best suited
to queries returning 45 rows or less. If you have more data than that,
it is recommended that you write your scripts to use
sqlite_unbuffered_query() instead for more optimal performance.
Does sqlite_fetch_all() have the same restriction? Is it the recommended
function for large amounts of data as sqlite_unbuffered_query()?
TIA


Regards, Andu Novac

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] R: [PHP-DB] SQLite

2003-07-07 Thread Alan D'Angelo - Media Beat Information Technology
Download a CHM version of manual !!


-Messaggio originale-
Da: Gerard Samuel [mailto:[EMAIL PROTECTED] 
Inviato: domenica 6 luglio 2003 1.16
A: [EMAIL PROTECTED]
Oggetto: [PHP-DB] SQLite

With respect to the PHP manual, are there any documentation to using 
this extention?
Thanks


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SQLite

2003-07-05 Thread Gerard Samuel
With respect to the PHP manual, are there any documentation to using 
this extention?
Thanks

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php