Re: [PHP] SqLite INSERT want not write
Bastien Koert On 2012-04-19, at 4:11 PM, Silvio Siefke wrote: > On Thu, 19 Apr 2012 13:00:40 -0700 > Tommy Pham wrote: > >> Technically, it's date('now') per [1] :) RTFM FTW! > > Yes its right, i have read it on sqlite.org. > > PS: Excuse me, what mean RTFM FTW? > Read The Fine Manual For The Win > > Regards > Silvio > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On Thu, 19 Apr 2012 13:00:40 -0700 Tommy Pham wrote: > Technically, it's date('now') per [1] :) RTFM FTW! Yes its right, i have read it on sqlite.org. PS: Excuse me, what mean RTFM FTW? Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On Thu, Apr 19, 2012 at 12:40 PM, siefke_lis...@web.de wrote: > Hello, > > On Thu, 19 Apr 2012 15:17:06 -0400 > "Steven Staples" wrote: > >> Ok, so I was wrong... ;) it does happen >> >> Try this: >> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, >> :teaser, :content);"; > > No errors, but no entry in the database. > > >> Or >> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> VALUES (NOW(), :autor, :title, :teaser, :content);"; > > > PDOException: SQLSTATE[HY000]: General error: 1 no such function: NOW > > Now is not availible in Sqlite, can use date, > Technically, it's date('now') per [1] :) RTFM FTW! http://www.sqlite.org/draft/lang_datefunc.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Hello, On Thu, 19 Apr 2012 20:43:52 +0100 Stuart Dallas wrote: > On 19 Apr 2012, at 20:40, siefke_lis...@web.de wrote: > > > On Thu, 19 Apr 2012 15:17:06 -0400 > > "Steven Staples" wrote: > What does the script output? The only path through your script that doesn't > display something is if there are missing $_POST elements, and the PDO errors > you've shown previously suggest that they're all present and correct. > > So if the thing is running correctly, regardless of what's going into the DB, > you should be getting some sort of output. Are you? Ah im so shamed now. I have only look at the size not in the database. I has make now a SELECT and all is well done. Im sorry, i should stopped try to "programming" with php. All is good, thank u so much. All wish nice rest of day or a nice day where ever you are. Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SqLite INSERT want not write
> -Original Message- > From: siefke_lis...@web.de [mailto:siefke_lis...@web.de] > Sent: April 19, 2012 3:40 PM > To: php-general@lists.php.net > Subject: Re: [PHP] SqLite INSERT want not write > > Hello, > > On Thu, 19 Apr 2012 15:17:06 -0400 > "Steven Staples" wrote: > > > Ok, so I was wrong... ;) it does happen > > > > Try this: > > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > >VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, > > :teaser, :content);"; > > No errors, but no entry in the database. > > > > Or > > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > >VALUES (NOW(), :autor, :title, :teaser, :content);"; > > > PDOException: SQLSTATE[HY000]: General error: 1 no such function: NOW > > Now is not availible in Sqlite, can use date, > > Which rights must have the database? > > siefke@gentoo-desk db $ ls -l > insgesamt 4 > -rw-rw-rw- 1 siefke siefke 4096 19. Apr 21:25 silviosiefke.db > > > Regards > Silvio > Ok, shot in the dark here are you closing your connection to the sqlite db? From what I see, you're not... when I was writing an app in Python, I remember having this issue, and because I didn't close the connection, it didn't commit the writes to the database... just a thought... Steve. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On 19 Apr 2012, at 20:40, siefke_lis...@web.de wrote: > On Thu, 19 Apr 2012 15:17:06 -0400 > "Steven Staples" wrote: > >> Ok, so I was wrong... ;) it does happen >> >> Try this: >> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, >> :teaser, :content);"; > > No errors, but no entry in the database. > > >> Or >> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> VALUES (NOW(), :autor, :title, :teaser, :content);"; > > > PDOException: SQLSTATE[HY000]: General error: 1 no such function: NOW > > Now is not availible in Sqlite, can use date, > > Which rights must have the database? > > siefke@gentoo-desk db $ ls -l > insgesamt 4 > -rw-rw-rw- 1 siefke siefke 4096 19. Apr 21:25 silviosiefke.db What does the script output? The only path through your script that doesn't display something is if there are missing $_POST elements, and the PDO errors you've shown previously suggest that they're all present and correct. So if the thing is running correctly, regardless of what's going into the DB, you should be getting some sort of output. Are you? -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Hello, On Thu, 19 Apr 2012 15:17:06 -0400 "Steven Staples" wrote: > Ok, so I was wrong... ;) it does happen > > Try this: > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, > :teaser, :content);"; No errors, but no entry in the database. > Or > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >VALUES (NOW(), :autor, :title, :teaser, :content);"; PDOException: SQLSTATE[HY000]: General error: 1 no such function: NOW Now is not availible in Sqlite, can use date, Which rights must have the database? siefke@gentoo-desk db $ ls -l insgesamt 4 -rw-rw-rw- 1 siefke siefke 4096 19. Apr 21:25 silviosiefke.db Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On Thu, Apr 19, 2012 at 2:17 PM, Steven Staples wrote: >> -Original Message- >> From: Silvio Siefke [mailto:siefke_lis...@web.de] >> Sent: April 19, 2012 3:11 PM >> To: php-general@lists.php.net >> Subject: Re: [PHP] SqLite INSERT want not write >> >> On Thu, 19 Apr 2012 14:57:04 -0400 >> "Steven Staples" wrote: >> >> > I think all you had to do was change this line: (line 27 in the >> > original >> > paste) >> > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) >> > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, >> > :teaser, :content);'; >> > >> > To this: >> > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) >> > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, >> > :teaser, :content);"; >> >> Thats end with: >> PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error >> >> I has changed what say Stuart, no Sytax errors but in the database nothing >> will write. >> >> Regards >> Silvio >> > > Ok, so I was wrong... ;) it does happen > > Try this: > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, > :teaser, :content);"; > > Or > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES (NOW(), :autor, :title, :teaser, :content);"; > > > The first example, you don't need the time(), and you had the date format > wrong... > The second example, uses the NOW() time, which is the timestamp for sql > > Maybe this time I will get it right ;) -- its been a long day, and it is > only 1/2 done > > Steve > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > For sqlite, you can specify the current datetime with just "now". So perhaps the insert statement could be simplified to: $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES(now, :autor, :title, :teaser, :content);"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SqLite INSERT want not write
> -Original Message- > From: Silvio Siefke [mailto:siefke_lis...@web.de] > Sent: April 19, 2012 3:11 PM > To: php-general@lists.php.net > Subject: Re: [PHP] SqLite INSERT want not write > > On Thu, 19 Apr 2012 14:57:04 -0400 > "Steven Staples" wrote: > > > I think all you had to do was change this line: (line 27 in the > > original > > paste) > > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) > > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > > :teaser, :content);'; > > > > To this: > > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > > :teaser, :content);"; > > Thats end with: > PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error > > I has changed what say Stuart, no Sytax errors but in the database nothing > will write. > > Regards > Silvio > Ok, so I was wrong... ;) it does happen Try this: $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title, :teaser, :content);"; Or $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES (NOW(), :autor, :title, :teaser, :content);"; The first example, you don't need the time(), and you had the date format wrong... The second example, uses the NOW() time, which is the timestamp for sql Maybe this time I will get it right ;) -- its been a long day, and it is only 1/2 done Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On Thu, 19 Apr 2012 14:57:04 -0400 "Steven Staples" wrote: > I think all you had to do was change this line: (line 27 in the original > paste) > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > :teaser, :content);'; > > To this: > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > :teaser, :content);"; Thats end with: PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error I has changed what say Stuart, no Sytax errors but in the database nothing will write. Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On 19 Apr 2012, at 19:57, Steven Staples wrote: > I think all you had to do was change this line: (line 27 in the original > paste) > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > :teaser, :content);'; > > To this: > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) > VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, > :teaser, :content);"; > > > The issue was (without looking any deeper) the quotes... > > Try that, and let us know. Still wrong. It should be as follows. $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES ('" . date( 'Y-m-s H:i:s', time() ) . "', :autor, :title, :teaser, :content);"; Incidentally, the time() in the date call is unnecessary since that's the default value for that parameter. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On 19 Apr 2012, at 19:52, Silvio Siefke wrote: > On Thu, 19 Apr 2012 13:21:46 -0500 > tamouse mailing lists wrote: > >> Maybe this will make the syntax errors stand out more: >> >> http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png > > > ok i have change it to the function date, but now i has the error > message: > > PDOException: SQLSTATE[HY000]: General error: 1 SQL logic error or missing > database > > gentoo-desk ~ # php -l test.php > No syntax errors detected in test.php > > The script now -> http://nopaste.info/63fe0a9148.html Using date() is not valid there. It's possible now() might work (don't use PDO so I dunno for sure), otherwise you'll need to bind that parameter in the same way you're binding the others. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SqLite INSERT want not write
> -Original Message- > From: Silvio Siefke [mailto:siefke_lis...@web.de] > Sent: April 19, 2012 2:53 PM > To: php-general@lists.php.net > Subject: Re: [PHP] SqLite INSERT want not write > > Hello, > > On Thu, 19 Apr 2012 13:21:46 -0500 > tamouse mailing lists wrote: > > > Maybe this will make the syntax errors stand out more: > > > > http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png > > > ok i have change it to the function date, but now i has the error > message: > > PDOException: SQLSTATE[HY000]: General error: 1 SQL logic error or missing > database > > The database is present, and the tables too. > > gentoo-desk db # ls > silviosiefke.db > gentoo-desk db # pwd > /var/www/silviosiefke_de/inc/db > > gentoo-desk ~ # php -l test.php > No syntax errors detected in test.php > > The script now -> http://nopaste.info/63fe0a9148.html > > Regards > Silvio I think all you had to do was change this line: (line 27 in the original paste) $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, :teaser, :content);'; To this: $sql = "INSERT INTO bloggen (date, autor, title, teaser, content) VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, :teaser, :content);"; The issue was (without looking any deeper) the quotes... Try that, and let us know. Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Hello, On Thu, 19 Apr 2012 13:21:46 -0500 tamouse mailing lists wrote: > Maybe this will make the syntax errors stand out more: > > http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png ok i have change it to the function date, but now i has the error message: PDOException: SQLSTATE[HY000]: General error: 1 SQL logic error or missing database The database is present, and the tables too. gentoo-desk db # ls silviosiefke.db gentoo-desk db # pwd /var/www/silviosiefke_de/inc/db gentoo-desk ~ # php -l test.php No syntax errors detected in test.php The script now -> http://nopaste.info/63fe0a9148.html Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Maybe this will make the syntax errors stand out more: http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On 19 Apr 2012, at 18:54, Silvio Siefke wrote: > On Thu, 19 Apr 2012 18:39:00 +0100 > Stuart Dallas wrote: > >> The script has syntax errors in it. You won't see those errors because PHP >> won't run a script with syntax errors, so it won't modify the >> error_reporting and display_errors settings. >> >> You can run php -l script.php to see those errors, but it would be better to >> set the error_reporting and display_errors values in php.ini on your >> development system/server. > > > gentoo-desk siefke # php -l test.php * > No syntax errors detected in test.php > > gentoo-desk blog # php -l manage.php > No syntax errors detected in manage.php > > gentoo-desk php # php -l db.php > No syntax errors detected in db.php > > > * I have written in this file only the php code. No syntax errors. > > gentoo-desk blog # php -v > PHP 5.3.10-pl0-gentoo with Suhosin-Patch (cli) (built: Apr 5 2012 00:31:12) > Copyright (c) 1997-2012 The PHP Group > Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies I took the code on http://nopaste.info/09e68c7e37.html and put it in test.php. stuart@fred:~$ php -l test.php Parse error: parse error in test.php on line 28 Errors parsing test.php You really can't see the mismatched quotes here? $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content) VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title, :teaser, :content);'; I'm using PHP 5.3.8 on this particular machine, not that it matters with basic syntax errors like this. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
Hello, On Thu, 19 Apr 2012 18:39:00 +0100 Stuart Dallas wrote: > The script has syntax errors in it. You won't see those errors because PHP > won't run a script with syntax errors, so it won't modify the error_reporting > and display_errors settings. > > You can run php -l script.php to see those errors, but it would be better to > set the error_reporting and display_errors values in php.ini on your > development system/server. gentoo-desk siefke # php -l test.php * No syntax errors detected in test.php gentoo-desk blog # php -l manage.php No syntax errors detected in manage.php gentoo-desk php # php -l db.php No syntax errors detected in db.php * I have written in this file only the php code. No syntax errors. gentoo-desk blog # php -v PHP 5.3.10-pl0-gentoo with Suhosin-Patch (cli) (built: Apr 5 2012 00:31:12) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SqLite INSERT want not write
On 19 Apr 2012, at 18:31, Silvio Siefke wrote: > i have a script which should write articles in a Sqlite 0database. The script > runs without errors, but nothing is written to the database. > > > The Script: http://nopaste.info/09e68c7e37.html > The db.php: http://nopaste.info/afd4dee47a.html > > The Database file has right 777. Has someone an idea? Thank u. The script has syntax errors in it. You won't see those errors because PHP won't run a script with syntax errors, so it won't modify the error_reporting and display_errors settings. You can run php -l script.php to see those errors, but it would be better to set the error_reporting and display_errors values in php.ini on your development system/server. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite if query changes to empty on a loop
On Thu, May 10, 2007 2:55 pm, [EMAIL PROTECTED] wrote: > Hello, > > I have a loop on an sqlite query which checks $domain until the status > of > $domain changes and then it deletes $domain. > > However when all the $domain items have been deleted I need the script > to > stop.. regardless of how many querys the loop > still has to run. So I want to detect when its empty and then stop. > > I have this... which does not work. > > $db = sqlite_open("whois.sqlite"); > > $x = 0; > while ($x < 9000) { > > $result = sqlite_query($db, "SELECT * FROM whois ORDER BY id"); > > // if (!$result) { > if (empty($result)) { > > echo "No data"; I dunno for sure what empty() is gonna do with $result, but I suspect that this message should say "query failed" rather than "no data" No data returned is not an error, it's just an empty set, which is very common. > } else { > > while ($row = sqlite_fetch_array($result)) { > > $domain = $row['name']; > > echo "$domain"; The quotes is kinda silly here... > $x++; > usleep(40); > } > } > } > sqlite_close($db); > ?> You said you were deleting things...? Where? What are you actually trying to do? "delete from whois" springs to mind as a MUCH better way from what you described, but not what you coded... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sqlite AND OR query ?
[EMAIL PROTECTED] wrote: > Hello, > > I want to select two dates one being todays date and the > other being -00-00 which just a date in the database when > no proper date has been entered. > > Ive tried this but it does not work... > > $today = date('Y-m-d'); > $result = sqlite_query($db, "SELECT * FROM domains WHERE date = > '-00-00' AND '$today'"); > > I just get items with '-00-00' returned or if I reverse it ie... > > WHERE date = '$today'AND '-00-00'"); > > I just get $today items returned. > > I also tried using OR instead of AND ie... > > WHERE date = '-00-00' OR '$today'"); > > But that seems to be returning all items in the db. > > > Thanks. SELECT * FROM domains WHERE (date = '-00-00' OR date = '$today') -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite AND OR query ?
Thanks Richard. - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: Sent: Wednesday, May 09, 2007 1:49 AM Subject: Re: [PHP] sqlite AND OR query ? On Tue, May 8, 2007 7:09 pm, [EMAIL PROTECTED] wrote: I want to select two dates one being todays date and the other being -00-00 which just a date in the database when no proper date has been entered. Ive tried this but it does not work... $today = date('Y-m-d'); $result = sqlite_query($db, "SELECT * FROM domains WHERE date = '-00-00' AND '$today'"); First of all, you can't just say "... AND '$today'" You need to say "... AND date = '$today' " When you say "... AND '$today' ": The database just converted $today into a TRUE/FALSE question. And since the only way to answer a T/F question is with 1/0 in a computer, it decides that $today is not 0, because it's got numbers ands stuff in it. So it's ALWAYS true. So your query really turned into: where today = '-00-00' and TRUE The "and TRUE" bit doesn't really do much, you see... $x AND TRUE === $x Actually, NULL might turn into false, if you have NULL dates. And for technical reasons, midnight of January 1, 1970, might turn into 0... But ignore that for now, as you're typing something silly anyway, and you want " where date = '-00-00' and date = '$today' " Next, think about this: date = '-00-00' AND date = '2007-05-08' Is it possible for any date to be = to both of those values at once? No. A date cannot be both -00-00 and also be today as well. Unless maybe you've invented a time machine... :-) I just get items with '-00-00' returned or if I reverse it ie... WHERE date = '$today'AND '-00-00'"); I just get $today items returned. I also tried using OR instead of AND ie... WHERE date = '-00-00' OR '$today'"); But that seems to be returning all items in the db. This, of course, turns into: date = '-00-00' OR TRUE and that is always TRUE: $x OR TRUE === TRUE Hope that helps. Technically, this was all SQL, but it applies equally well in PHP with && and any programming language. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite AND OR query ?
On Tue, May 8, 2007 7:09 pm, [EMAIL PROTECTED] wrote: > I want to select two dates one being todays date and the other being > -00-00 which just a date > in the database when no proper date has been entered. > > Ive tried this but it does not work... > > $today = date('Y-m-d'); > $result = sqlite_query($db, "SELECT * FROM domains WHERE date = > '-00-00' > AND '$today'"); First of all, you can't just say "... AND '$today'" You need to say "... AND date = '$today' " When you say "... AND '$today' ": The database just converted $today into a TRUE/FALSE question. And since the only way to answer a T/F question is with 1/0 in a computer, it decides that $today is not 0, because it's got numbers ands stuff in it. So it's ALWAYS true. So your query really turned into: where today = '-00-00' and TRUE The "and TRUE" bit doesn't really do much, you see... $x AND TRUE === $x Actually, NULL might turn into false, if you have NULL dates. And for technical reasons, midnight of January 1, 1970, might turn into 0... But ignore that for now, as you're typing something silly anyway, and you want " where date = '-00-00' and date = '$today' " Next, think about this: date = '-00-00' AND date = '2007-05-08' Is it possible for any date to be = to both of those values at once? No. A date cannot be both -00-00 and also be today as well. Unless maybe you've invented a time machine... :-) > I just get items with '-00-00' returned or if I reverse it ie... > > WHERE date = '$today'AND '-00-00'"); > > I just get $today items returned. > > I also tried using OR instead of AND ie... > > WHERE date = '-00-00' OR '$today'"); > > But that seems to be returning all items in the db. This, of course, turns into: date = '-00-00' OR TRUE and that is always TRUE: $x OR TRUE === TRUE Hope that helps. Technically, this was all SQL, but it applies equally well in PHP with && and any programming language. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLite /how can I install on an Apache virtual host?
Many thanks. Several good points you made. I should recompile rather than use just any old binary. I found it on the net. I wasn't clear how to tell the php.ini how to interpret the extension. I can't to run command lines on the host, so its a bit of a bother to compile stuff there. I've had some success using phpshell. Curt Zirzow wrote: * Thus wrote Al ([EMAIL PROTECTED]): I've got a website on an Apache virtual host and would like to install the SQLite library. Can someone give me a brief outline of what I need to do or point me to a good writeup? some info on sqlite: http://php.net/sqlite You can compile and install the extension from the source located here: http://pecl.php.net/sqlite My host makes it tough to run command line code to make files, etc. I've found a a Linux binary [sqlite.so]. And, they provide a means to customize the php.ini. You found it on your virtual host machine? or somewhere on the internet? I wouldnt trust any old .so laying around somewhere. If its on your virtual host machine already then you can just add this to your php.ini (assuming its in your extension path) extension=sqlite.so Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLite /how can I install on an Apache virtual host?
* Thus wrote Al ([EMAIL PROTECTED]): > I've got a website on an Apache virtual host and would like to install > the SQLite library. > > Can someone give me a brief outline of what I need to do or point me to > a good writeup? some info on sqlite: http://php.net/sqlite You can compile and install the extension from the source located here: http://pecl.php.net/sqlite > > My host makes it tough to run command line code to make files, etc. > > I've found a a Linux binary [sqlite.so]. And, they provide a means to > customize the php.ini. You found it on your virtual host machine? or somewhere on the internet? I wouldnt trust any old .so laying around somewhere. If its on your virtual host machine already then you can just add this to your php.ini (assuming its in your extension path) extension=sqlite.so Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLite Support is library call?
DAvid Jackson wrote: Howdy -- SQLite supported by a direct call the sqlite library? As apposed to calling the executable? Could I use ini_set(include_path=) to tall PHP where the SQLite lib is located? TIA, David I have never worked with SQLite but I bet you cannot. 1. the library is linked at php startup 2. enviroment variables LD_* are used to indicate another library to link 3. it is not secure, the library could do anything -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLITE
* Thus wrote Bronislav Kluèka ([EMAIL PROTECTED]): > 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 Read the sqlite faq: http://sqlite.org/faq.html#q7 Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: [PHP-DB] Re: [PHP] SQLITE
That's my code: $dbfile="db.sdb"; $db=sqlite_open($dbfile); $res=sqlite_query($db,"select a.*,b.* from a left join b on a.id=b.id_a where a.name like \"%1%\" or b.street like \"%1%\" order by cellphone"); echo sqlite_num_rows($res).CRLF; sqlite_close($db); It's realy just "benchmark" I've done. I'm pretty much aware of system sqlite is useing to store the data, and I also find obvious that if it would be runnig like web database module, users will ask the same table ata the same time (like with other db system, they are looking at the same page) but I find it not good, I was only asking if there is a "way to change it" Bronislav Klucka > > > Is this some feature of sqlite or an I doing something wrong? > > Without seeing any code or being given any details, all I can make is an > educated guess. SQLite uses the filesystem for storage. If your queries > are needing to access the same file (maybe you're querying the same > table), SQLite is going to serialize those queries to help you avoid > threading problems. So, your queries are going to basically take turns. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLITE
--- Bronislav_Kluèka <[EMAIL PROTECTED]> wrote: > Hi, I've got questions: I only noticed one. > 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 [snip] > Is this some feature of sqlite or an I doing something wrong? Without seeing any code or being given any details, all I can make is an educated guess. SQLite uses the filesystem for storage. If your queries are needing to access the same file (maybe you're querying the same table), SQLite is going to serialize those queries to help you avoid threading problems. So, your queries are going to basically take turns. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite
On Sun, 24 Aug 2003 14:44:19 +1000 Kevin Waterson <[EMAIL PROTECTED]> wrote: > This one time, at band camp, andu <[EMAIL PROTECTED]> wrote: > > > $command="sqlite db_name '.dump'"; > > exec($command,$result); > > print_r( $result);// shows the dump array > > As sqlite is bundled with php5, I guess command line type commands > are not available because it is compiled in. Something like that, I use it as a separately compiled dynamic library with php4 though. > > Kevin > > > -- > __ > (_ \ > _) ) > | / / _ ) / _ | / ___) / _ ) > | | ( (/ / ( ( | |( (___ ( (/ / > |_| \) \_||_| \) \) > Kevin Waterson > Port Macquarie, Australia > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- Andu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite
This one time, at band camp, andu <[EMAIL PROTECTED]> wrote: > $command="sqlite db_name '.dump'"; > exec($command,$result); > print_r( $result);// shows the dump array As sqlite is bundled with php5, I guess command line type commands are not available because it is compiled in. Kevin -- __ (_ \ _) ) | / / _ ) / _ | / ___) / _ ) | | ( (/ / ( ( | |( (___ ( (/ / |_| \) \_||_| \) \) Kevin Waterson Port Macquarie, Australia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sqlite
On Sun, 24 Aug 2003 13:09:55 +1000 Kevin Waterson <[EMAIL PROTECTED]> wrote: > I am writing an admin for sqlite but have struck a > problem with exporting data. I wish to simply > get a dump of the current sql database. from > the commandline this would be done with .dump > however this causes an error when used with > sqlite_query() > > Is there any other method to get a sqlite dump? I just installed the sqlite extension today myself and was looking for all those dot commands but I don't think they are supported by the extension unfortunately. My suggestion is to call sqlite with exec() in order to get the .dump. $command="sqlite db_name '.dump'"; exec($command,$result); print_r( $result);// shows the dump array > > Kind regards > kevin > > -- > __ > (_ \ > _) ) > | / / _ ) / _ | / ___) / _ ) > | | ( (/ / ( ( | |( (___ ( (/ / > |_| \) \_||_| \) \) > Kevin Waterson > Port Macquarie, Australia > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- Andu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php