You are here: Re: PHP and SQLIte: UPDATE statement fails « PHP Programming Language « IT news, forums, messages
Re: PHP and SQLIte: UPDATE statement fails

Posted by Luigi on 11/22/07 14:57

OK, I moved to PDO, but the problem still remains even if different as
I write more over here belove

> - Do you have unfinished transactions in your code?
> A missing COMMIT will rollback your db at the end.

There is, as you can see in the code below...

> - Is the sqlite file write protected (win32) or not
> writable by your web server user (linux)?

-rw-rw-rw-

> - Did you correctly configure the error_reporting
> for your PHP installation?

I don't know... this is the value I've got: 6143, but I have not idea
about what it means... I'm a newbie...

> - echo() the update statement. Does this exact statement
> work when performed manually with another sqlite tool?

Yes, it does perfectly...

Here is my full code:

<?php

try {
$dbh = new PDO('sqlite:../sqlite/myslite.db');

$statement = "update myusers set passwd='".md5('xxx')."' where
id='xxx'";
echo $statement, "\n";

$dbh->beginTransaction();
$dbh->execute($statement);
$dbh->commit();

$sth = $dbh->query('SELECT * from myusers');
foreach($sth as $row) {
echo $row['id'], "\n";
}
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
} catch (Exception $e) {
$dbh->rollBack();
echo "Failed: " . $e->getMessage();
}

?>

The problem is that now it prints out only $statement, and doesn't
prints the list of ids... if there were an error it would be printed,
but it isn't! Nonetheless something happens here:

$dbh->beginTransaction();
$dbh->execute($statement);
$dbh->commit();

In fact if I comment it, the id list is printed...

I'm very confused...

Thanks for your help...

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация