Re: [sqlite] Insert not working for sqlite3
Dear all, This time the code below work perfectly! exec("drop table if exists tbl2"); $dbh->exec("create table tbl2 (one varchar(10),two varchar(10))"); $dbh->exec("insert into tbl2 values('test1a','test2a')"); $dbh->exec("insert into tbl2 values('test1b','test2b')"); $dbh->exec("insert into tbl2 values('test1c','test2c')"); $dbh->exec("insert into tbl2 values('test1d','test2d')"); $result=$dbh->query('select * from tbl2'); foreach($result as $row) { print "row=".$row['one'].",".$row['two']."\n"; } $dbh=NULL; print "Done\n"; } catch(PDOException $e) { print "Exception: ".$e->getMessage(); } ?> I managed to find out why yesterday's code is not working: $result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); actually if I remove the "$result=", directly put as below: $dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); Then it also works. So thank you so much everybody! James - Original Message From: "Black, Michael (IS)" To: General Discussion of SQLite Database Sent: Mon, 11 July, 2011 9:18:30 PM Subject: Re: [sqlite] Insert not working for sqlite3 If CREATE has no return why do I get a return? To be clear I'm using PHP 5.3.6 and it most definitely gets a return But I re-wrote this according to some PDO examples I found. This is a more complete example. You should be able to run this with a PHP command line -- forget the web interface until you get this working. If the database can't be opened you'll get an exception. If this doesn't work then open up the database with sqlite3 and .dump it. exec("drop table if exists tbl2"); $dbh->exec("create table tbl2 (one varchar(10),two varchar(10))"); $dbh->exec("insert into tbl2 values('test1a','test2a')"); $dbh->exec("insert into tbl2 values('test1b','test2b')"); $dbh->exec("insert into tbl2 values('test1c','test2c')"); $dbh->exec("insert into tbl2 values('test1d','test2d')"); $result=$dbh->query('select * from tbl2'); foreach($result as $row) { print "row=".$row['one'].",".$row['two']."\n"; } $dbh=NULL; print "Done\n"; } catch(PDOException $e) { print "Exception: ".$e->getMessage(); } ?> This displays this output D:\SQLite>php -e enabled SQLite3 module version => 0.7-dev SQLite Library => 3.7.4 Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Stephan Beal [sgb...@googlemail.com] Sent: Monday, July 11, 2011 6:10 AM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Insert not working for sqlite3 On Mon, Jul 11, 2011 at 2:41 AM, James_21th wrote: > $result=$dbh->query("create table tbl2 (one varchar(10),two > varchar(10));"); > A CREATE statement has no results. In PDO, only SELECT (and similar) return a result, if i'm not mistaken. -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On 11 Jul 2011, at 2:18pm, Black, Michael (IS) wrote: > If CREATE has no return why do I get a return? Whoever wrote that isn't familiar with SQLite's habits. They don't know that most SQLite functions return a result code rather than some piece of data relating to the operating. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
If CREATE has no return why do I get a return? To be clear I'm using PHP 5.3.6 and it most definitely gets a return But I re-wrote this according to some PDO examples I found. This is a more complete example. You should be able to run this with a PHP command line -- forget the web interface until you get this working. If the database can't be opened you'll get an exception. If this doesn't work then open up the database with sqlite3 and .dump it. exec("drop table if exists tbl2"); $dbh->exec("create table tbl2 (one varchar(10),two varchar(10))"); $dbh->exec("insert into tbl2 values('test1a','test2a')"); $dbh->exec("insert into tbl2 values('test1b','test2b')"); $dbh->exec("insert into tbl2 values('test1c','test2c')"); $dbh->exec("insert into tbl2 values('test1d','test2d')"); $result=$dbh->query('select * from tbl2'); foreach($result as $row) { print "row=".$row['one'].",".$row['two']."\n"; } $dbh=NULL; print "Done\n"; } catch(PDOException $e) { print "Exception: ".$e->getMessage(); } ?> This displays this output D:\SQLite>php -e enabled SQLite3 module version => 0.7-dev SQLite Library => 3.7.4 Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate ____________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Stephan Beal [sgb...@googlemail.com] Sent: Monday, July 11, 2011 6:10 AM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Insert not working for sqlite3 On Mon, Jul 11, 2011 at 2:41 AM, James_21th wrote: > $result=$dbh->query("create table tbl2 (one varchar(10),two > varchar(10));"); > A CREATE statement has no results. In PDO, only SELECT (and similar) return a result, if i'm not mistaken. -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Mon, Jul 11, 2011 at 2:41 AM, James_21th wrote: > $result=$dbh->query("create table tbl2 (one varchar(10),two > varchar(10));"); > A CREATE statement has no results. In PDO, only SELECT (and similar) return a result, if i'm not mistaken. -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On 11 Jul 2011, at 1:41am, James_21th wrote: > I ran exactly the code you put below, but it only return: bool(false) > > try { > $dbh = new PDO('sqlite:db1.db'); > $result=$dbh->query("drop table if exists tbl2"); > $result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); > var_dump($result); > } > catch(PDOException $e) > { > print "Oops!\n"; > print 'Exception : '.$e->getMessage()."\n"; > } > ?> Please specify a complete file path for your database file, and make sure that that folder can be written to by your web process. Probably easiest to make it globally writable just for testing. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
Hi, I ran exactly the code you put below, but it only return: bool(false) query("drop table if exists tbl2"); $result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); } catch(PDOException $e) { print "Oops!\n"; print 'Exception : '.$e->getMessage()."\n"; } ?> - Original Message From: "Black, Michael (IS)" To: General Discussion of SQLite Database Sent: Fri, 8 July, 2011 8:27:35 PM Subject: Re: [sqlite] Insert not working for sqlite3 I downloaded 5.3.6 from here -- I used the Thread Safe version Installer. http://windows.php.net/download/ And you're script ran just fine and created this: sqlite> .dump PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE tbl2 (one varchar(10),two varchar(10)); COMMIT; I the modified your script to run a bit better as you will see "false" the 2nd time your script is run as the table already exists. query("drop table if exists tbl2"); $result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); } catch(PDOException $e) { print "Oops!\n"; print 'Exception : '.$e->getMessage()."\n"; } ?> So now every time I run it we get this: D:\php>php string(52) "create table tbl2 (one varchar(10),two varchar(10));" } Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of James_21th [james_2...@yahoo.com] Sent: Thursday, July 07, 2011 8:50 PM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Insert not working for sqlite3 Dear all, Thank you for all your valuable suggestion, it's good idea to put the whole script here, also good idea everytime to check the result, so I put the whole script here: The $result always return false, it don't allow me to create a simple table, the table name surely not exist, I change tbl3, 4, 5, all not able to create. (that could be the same reason why insert is not working, if not even able to create table, let alone insert.) query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); ?> - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 9:18:07 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 2:17 PM, Simon Slavin wrote: > For each operation you should test the $result and check to see it's > SQLITE_OK. > Or enable exceptions and you don't have to check for errors (because they will cause an exception). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Fri, Jul 8, 2011 at 3:50 AM, James_21th wrote: > The $result always return false, it don't allow me to create a simple > table, the > table name surely not exist, I change tbl3, 4, 5, all not able to create. > (that > could be the same reason why insert is not working, if not even able to > create > table, let alone insert.) > Are you running this over the web or the command line? If you are running over the web, make sure that the web server's user has access to write the db file AND to the write to the directory containing the db file (it needs this in order to write the journal). > > $dbh = new PDO('sqlite:db1.db'); > $result=$dbh->query("create table tbl2 (one varchar(10),two > varchar(10));"); > var_dump($result); > ?> > Can you show us the OUTPUT of that command? And i highly recommend reading: http://www.catb.org/~esr/faqs/smart-questions.html -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
I downloaded 5.3.6 from here -- I used the Thread Safe version Installer. http://windows.php.net/download/ And you're script ran just fine and created this: sqlite> .dump PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE tbl2 (one varchar(10),two varchar(10)); COMMIT; I the modified your script to run a bit better as you will see "false" the 2nd time your script is run as the table already exists. query("drop table if exists tbl2"); $result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); } catch(PDOException $e) { print "Oops!\n"; print 'Exception : '.$e->getMessage()."\n"; } ?> So now every time I run it we get this: D:\php>php string(52) "create table tbl2 (one varchar(10),two varchar(10));" } Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of James_21th [james_2...@yahoo.com] Sent: Thursday, July 07, 2011 8:50 PM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Insert not working for sqlite3 Dear all, Thank you for all your valuable suggestion, it's good idea to put the whole script here, also good idea everytime to check the result, so I put the whole script here: The $result always return false, it don't allow me to create a simple table, the table name surely not exist, I change tbl3, 4, 5, all not able to create. (that could be the same reason why insert is not working, if not even able to create table, let alone insert.) query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); ?> - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 9:18:07 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 2:17 PM, Simon Slavin wrote: > For each operation you should test the $result and check to see it's > SQLITE_OK. > Or enable exceptions and you don't have to check for errors (because they will cause an exception). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On 8 Jul 2011, at 2:50am, James_21th wrote: > $dbh = new PDO('sqlite:db1.db'); Make sure "extension=php_pdo_sqlite.dll" is enabled in php.ini. Do a find on 'sqlite' in it and see if anything looks disabled. Specify a full path for you database file, e.g. sqlite:/opt/databases/mydb.sq3 Make sure that your Apache process has permission to create and write in that folder. Possibly easiest to debug this problem by making a folder that everything can write to. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
Dear all, Thank you for all your valuable suggestion, it's good idea to put the whole script here, also good idea everytime to check the result, so I put the whole script here: The $result always return false, it don't allow me to create a simple table, the table name surely not exist, I change tbl3, 4, 5, all not able to create. (that could be the same reason why insert is not working, if not even able to create table, let alone insert.) query("create table tbl2 (one varchar(10),two varchar(10));"); var_dump($result); ?> - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 9:18:07 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 2:17 PM, Simon Slavin wrote: > For each operation you should test the $result and check to see it's > SQLITE_OK. > Or enable exceptions and you don't have to check for errors (because they will cause an exception). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Thu, Jul 7, 2011 at 2:17 PM, Simon Slavin wrote: > For each operation you should test the $result and check to see it's > SQLITE_OK. > Or enable exceptions and you don't have to check for errors (because they will cause an exception). -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On 7 Jul 2011, at 6:52am, James_21th wrote: > $dbh = new PDO('sqlite:test.db'); > $result=$dbh->query("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); Make one application which does DROP table IF EXISTS CREATE the table Do the INSERT as above Do a SELECT for that data For each operation you should test the $result and check to see it's SQLITE_OK. You do not need to specify a transaction (BEGIN/COMMIT). SQLite will do it for you. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
You're going to have to create a complete stand-alone example if you want us to debug your code for you. Make a simple program that only does that one insert and share that with us. Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of James_21th [james_2...@yahoo.com] Sent: Thursday, July 07, 2011 3:09 AM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Insert not working for sqlite3 semicolon added and tried again, still no use. - Original Message From: Michael Stephenson To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 3:46:35 PM Subject: Re: [sqlite] Insert not working for sqlite3 What if you put a semicolon at the end of the query text? -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of James_21th Sent: Thursday, July 07, 2011 3:32 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] Insert not working for sqlite3 Yes, 100% sure, because I only have one copy on my PC, and the script which can display the db's data also on the same directory. I also tried below, but no error captured, just nothing happened. try { $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); } catch(PDOExecption $e) { print "Error!: " . $e->getMessage() . ""; } - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 2:27:34 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 8:24 AM, James_21th wrote: > The table already created with some data inside, the existing data can > be display use "select * from tbl1". Are you 100% sure that the test.db being opened here is the same test.db being used in the rest of he code (same directory)? -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
Are you missing a COMMIT perhaps? On 7 July 2011 09:11, Stephan Beal wrote: > On Thu, Jul 7, 2011 at 9:31 AM, James_21th wrote: > > > try { > > $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); > > } catch(PDOExecption $e) { > > print "Error!: " . $e->getMessage() . ""; > > } > > > > PDO _only_ throws exceptions if you set the exceptions reporting option. > Try > instantiating it like this: > >$attr = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); >$dbh = new PDO($dsn, "", "", $attr ); > > -- > - stephan beal > http://wanderinghorse.net/home/stephan/ > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Thu, Jul 7, 2011 at 9:31 AM, James_21th wrote: > try { > $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); > } catch(PDOExecption $e) { > print "Error!: " . $e->getMessage() . ""; > } > PDO _only_ throws exceptions if you set the exceptions reporting option. Try instantiating it like this: $attr = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); $dbh = new PDO($dsn, "", "", $attr ); -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
semicolon added and tried again, still no use. - Original Message From: Michael Stephenson To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 3:46:35 PM Subject: Re: [sqlite] Insert not working for sqlite3 What if you put a semicolon at the end of the query text? -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of James_21th Sent: Thursday, July 07, 2011 3:32 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] Insert not working for sqlite3 Yes, 100% sure, because I only have one copy on my PC, and the script which can display the db's data also on the same directory. I also tried below, but no error captured, just nothing happened. try { $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); } catch(PDOExecption $e) { print "Error!: " . $e->getMessage() . ""; } - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 2:27:34 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 8:24 AM, James_21th wrote: > The table already created with some data inside, the existing data can > be display use "select * from tbl1". Are you 100% sure that the test.db being opened here is the same test.db being used in the rest of he code (same directory)? -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
What if you put a semicolon at the end of the query text? -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of James_21th Sent: Thursday, July 07, 2011 3:32 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] Insert not working for sqlite3 Yes, 100% sure, because I only have one copy on my PC, and the script which can display the db's data also on the same directory. I also tried below, but no error captured, just nothing happened. try { $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); } catch(PDOExecption $e) { print "Error!: " . $e->getMessage() . ""; } - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 2:27:34 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 8:24 AM, James_21th wrote: > The table already created with some data inside, the existing data can > be display use "select * from tbl1". Are you 100% sure that the test.db being opened here is the same test.db being used in the rest of he code (same directory)? -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
Yes, 100% sure, because I only have one copy on my PC, and the script which can display the db's data also on the same directory. I also tried below, but no error captured, just nothing happened. try { $result=$dbh->exec("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); } catch(PDOExecption $e) { print "Error!: " . $e->getMessage() . ""; } - Original Message From: Stephan Beal To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 2:27:34 PM Subject: Re: [sqlite] Insert not working for sqlite3 On Thu, Jul 7, 2011 at 8:24 AM, James_21th wrote: > The table already created with some data inside, the existing data can be > display use "select * from tbl1". Are you 100% sure that the test.db being opened here is the same test.db being used in the rest of he code (same directory)? -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Thu, Jul 7, 2011 at 8:24 AM, James_21th wrote: > The table already created with some data inside, the existing data can be > display use "select * from tbl1". Are you 100% sure that the test.db being opened here is the same test.db being used in the rest of he code (same directory)? -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
The table already created with some data inside, the existing data can be display use "select * from tbl1". - Original Message From: Michael Stephenson To: General Discussion of SQLite Database Sent: Thu, 7 July, 2011 1:59:40 PM Subject: Re: [sqlite] Insert not working for sqlite3 I don't see something like a "create table tbl1(one, two);" statement. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of James_21th Sent: Thursday, July 07, 2011 1:52 AM To: General Discussion of SQLite Database Subject: [sqlite] Insert not working for sqlite3 Dear all, I'm able to connect to sqlite3 DB and display the data inside, but when insert data, no matter how to try, just don't work, there's no error, but no data inserted. Below is the simple PDO SQL I'm using, table name is "tbl1", the two fields name is just "one" & "two": $dbh = new PDO('sqlite:test.db'); $result=$dbh->query("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); Any feed back will be greately appreciated! Regards! James ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
On Thu, Jul 7, 2011 at 7:52 AM, James_21th wrote: > Dear all, > > I'm able to connect to sqlite3 DB and display the data inside, but when > insert > data, no matter how to try, just don't work, there's no error, but no data > inserted. > ... > Any feed back will be greately appreciated! > See: http://www.php.net/manual/en/pdo.error-handling.php and enable exception throwing. Then any errors will throw an exception and the problem will be easy to track down. -- - stephan beal http://wanderinghorse.net/home/stephan/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Insert not working for sqlite3
I don't see something like a "create table tbl1(one, two);" statement. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of James_21th Sent: Thursday, July 07, 2011 1:52 AM To: General Discussion of SQLite Database Subject: [sqlite] Insert not working for sqlite3 Dear all, I'm able to connect to sqlite3 DB and display the data inside, but when insert data, no matter how to try, just don't work, there's no error, but no data inserted. Below is the simple PDO SQL I'm using, table name is "tbl1", the two fields name is just "one" & "two": $dbh = new PDO('sqlite:test.db'); $result=$dbh->query("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); Any feed back will be greately appreciated! Regards! James ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Insert not working for sqlite3
Dear all, I'm able to connect to sqlite3 DB and display the data inside, but when insert data, no matter how to try, just don't work, there's no error, but no data inserted. Below is the simple PDO SQL I'm using, table name is "tbl1", the two fields name is just "one" & "two": $dbh = new PDO('sqlite:test.db'); $result=$dbh->query("INSERT INTO tbl1(one,two) VALUES ('new1','new2')"); Any feed back will be greately appreciated! Regards! James ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users