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 Oliver Grδtz on 11/22/07 19:06

Luigi schrieb:
> 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...

That's the numeric value of the sum of your error level constants:

http://de.php.net/error_reporting

It means E_ALL, so you should see all types of error messages.

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

Typo alert "myslite" vs "mysqlite"?
Are you working on the wrong database?

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

This MUST yield an error message since PDO has no execute method:

Fatal error: Call to undefined method PDO::execute() in C:\test.php on
line 9

> $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();

So you are only doing a rollback if the error is NOT a database error???

The script worked for me after changing to exec() and creating a mini
database.

OLLi

--
"No more Mr. Nice Gaius!!!"
[Baltar on Battlestar Galactica 107]

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация