|  | Posted by NC on 11/22/07 21:51 
On Nov 22, 12:18 am, Luigi <luigipai...@libero.it> wrote:>
 > I'm a newbie in PHP. I have written a short script that tries to
 > update a SQLite database with the user data. It is pretty simple,
 > something like this:
 >
 > $sqlite = sqlite_open("mytest.db", 0666, $sqlite_error);
 > if(!$sqlite) {
 >     die("Sqlite error: ".$sqlite_error);
 > }
 > $statement = "update myusers set mail=\"mymail\" where name=\"myuser\"";
 > sqlite_query($sqlite, $statement);
 > sqlite_close($sqlite);
 >
 > ?>
 >
 > It's just a test, but it doesn't work. It doesn't give me any error,
 > but the table is not updated. Can you suggest me a possible reason?
 
 For starters, you might want to replace double quotes in the query
 with single quotes, just to make sure you are passing literals, rather
 than identifiers:
 
 http://www.sqlite.org/lang_keywords.html
 
 Then, you need to check if execution of your query returned an error;
 right now, you have this at the end of your script:
 
 sqlite_query($sqlite, $statement);
 sqlite_close($sqlite);
 
 Change it to something like this:
 
 $result = sqlite_query($sqlite, $statement, SQLITE_ASSOC,
 $sqlite_error);
 if ($result == false) {
 die("Sqlite error: " . $sqlite_error);
 }
 sqlite_close($sqlite);
 
 Cheers,
 NC
  Navigation: [Reply to this message] |