Sliipeetais Posted August 9, 2004 Report Share Posted August 9, 2004 Formāts ierakstam datubaazee - yyyy-mm-dd hh:mm:ss Formāts mainīgajam - yyyy-mm-dd hh:mm:ss Ideja - iezīmeet visus, kur ieraksts datubāzē > par mainīgo. Kā? Link to comment Share on other sites More sharing options...
bubu Posted August 9, 2004 Report Share Posted August 9, 2004 Ko nozīmē izīmēt? Ja tu domā izselektēt, tad: SELECT * FROM tabula WHERE lauks > '$vertiba' Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 9, 2004 Author Report Share Posted August 9, 2004 Aizmirsu pateikt ļoti svarīgu elementu - formāts datubāzē ir DATETIME. Un datetime salīdzināšana ar parastu stringu man kaut kā nesanāk. Link to comment Share on other sites More sharing options...
bubu Posted August 9, 2004 Report Share Posted August 9, 2004 SELECT * FROM tabula WHERE lauks > CAST('$vertiba' AS DATETIME) Ūze ze manual! Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 10, 2004 Author Report Share Posted August 10, 2004 Emm, paldies. Esmu tāds nepraša, ka manuālī neko neatradu. Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 Tomēr netieku galā. Man ir mainīgais $datums="2004-07-28"; Vēl man ir datubāze, kur ir daudz, daudz lauciņi (datetime) ar "2004-07-28 00:00" stila ierakstiem. Mans mērķis ir no datubāzes atlasīt visus lauciņus, kuros datums ir mazāks par $datums. Lūk kā to daru es: $sql=mysql_query("SELECT * FROM tabula WHERE time=CAST($datums AS DATETIME)"); Nu nesānāk. Nekādi. Link to comment Share on other sites More sharing options...
bubu Posted August 21, 2004 Report Share Posted August 21, 2004 Varbūt pamēģini ielikt pēdiņās, un ja jau gribi atlasīt ierakstus ar mazākiem datumiem, tad jau lieto < nevis = $sql=mysql_query("SELECT * FROM tabula WHERE `time`<CAST('$datums' AS DATETIME)"); Un kas notiek, kad tu izpildi kveriju? Neko neatlasa, vai kādu kļūdu atgriež? Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 (edited) Ehh, es te vispār saputrojos Tagad ir: $sql=mysql_query("SELECT * FROM tabula WHERE 'time'<CAST('$datums' AS DATE)"); Un vienalga - mysql_fetch_array(): supplied argument is not a valid MySQL result resource Edited August 21, 2004 by Sliipeetais Link to comment Share on other sites More sharing options...
bubu Posted August 21, 2004 Report Share Posted August 21, 2004 Nu tad izdrukā kļūdas paziņojumu, mysql_error(), kā ta citādi var kautko pateikt, ja nekā nezinu? Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 mysql_fetch_array(): supplied argument is not a valid MySQL result resource Link to comment Share on other sites More sharing options...
bubu Posted August 21, 2004 Report Share Posted August 21, 2004 (edited) To saka PHP, bet ko mysql saka? Tak pēc mysql_query izsaukšanas uzliec šādu rindiņu: echo echo mysql_errno($link) . ": " . mysql_error($link) . "\n"; Edited August 21, 2004 by bubu Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 (edited) Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in C:\swamp\www\functions.php on line 489 Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\swamp\www\functions.php on line 489 : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\swamp\www\functions.php on line 491 Edited August 21, 2004 by Sliipeetais Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 Kas ir tas $link? Link to comment Share on other sites More sharing options...
bubu Posted August 21, 2004 Report Share Posted August 21, 2004 Tas ir tas, ko atgriež mysql_connect. Var jau arī šādi rakstīt: echo mysql_errno() . ": " . mysql_error() . "\n"; Link to comment Share on other sites More sharing options...
Sliipeetais Posted August 21, 2004 Author Report Share Posted August 21, 2004 1064: You have an error in your SQL syntax near '('2004-06-21' AS DATE)' at line 1 Link to comment Share on other sites More sharing options...
Recommended Posts