KryPt0 Posted March 23, 2006 Report Share Posted March 23, 2006 Tātad kārtējais skripts, kuram kaut kas nepatīk :( Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\new\addons\cw\index.php on line 7 <?php $db = mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db('gbook') or die(mysql_error()); $sql[getPosts] = mysql_query("SELECT name, email, message, date, FROM guestbook order by id DESC LIMIT 10"); while($data = mysql_fetch_array($sql[getPosts])) { $post_date = date('D F jS Y @ g:ia', $data[date]); echo "<div>On $post_date <a href=\"mailto:$data[email]\">$data[user]</a> said:</div>\n"; echo "<div>$data[message]</div>\n\n"; } mysql_close($db); ?> Šī ir pievienošana un arī neko nepievieno :( : <?php if($_POST['submit']) { $db = mysql_connect('localhost','root','') or die(mysql_errno().' : '.mysql_error()); mysql_select_db('gbook') or die(mysql_errno().' : '.mysql_error()); $sql[addpost] = mysql_query("INSERT INTO guestbook (name, email, message, date) VALUES ('$_POST[name]','$_POST[email]','$_POST[message]',time())"); mysql_close($db); echo "Thanks ".$_POST['name']." your message has been added\n"; } ?> Domāju, ka formas kodu likt nav vērts :/ Parasta forma, bet janu tomēr vajag tad šeit būs: http://paste.php.lv/3492 EDIT: Parcik PHP kodi ir īsi, tad lieku šeit nevis paste.php.lv Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 23, 2006 Report Share Posted March 23, 2006 (edited) ('$_POST[name]','$_POST','$_POST[message]',time())"); nekorekti dati... $_POST[name] --> truukst peedinju $_POST['name'] Esmu n reizes teicis testeeshanai izmantojiet ECHO un masiiviem PRINT_R() ... izvadi to queriju uz ekraana un redzeesi vai vinsh ir korekts... + uzinstalee teiksim PHPMyAdmin un tur ir textarea lauks kur vari iekopeet to izvadiito kveriju un skatiities kaads ir rez. + pielabot vinju kameer ir taa kaa vajag.... P.S. ja to buutu izdarijis tad pats pamaniitu ka netiek padoti dati.... un nebuutu jastreso... pamaniju vel ko time() ??? manupraat iisti korekti tas nav... Edited March 23, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
KryPt0 Posted March 23, 2006 Author Report Share Posted March 23, 2006 <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $date = date('d.m.Y,H:i'); if($_POST['submit']) { $db = mysql_connect('localhost','root','') or die(mysql_errno().' : '.mysql_error()); mysql_select_db('gbook') or die(mysql_errno().' : '.mysql_error()); $sql[addpost] = mysql_query("INSERT INTO `guestbook` (`name`,`email`,`message`,`date`) VALUES ('$name', '$email', '$message', '$date');"); mysql_close($db); echo "Thanks ".$name. " your message has been added\n"; } ?> Tātad tagat viņš pievieno visu datubāze, bet nevēlās pielikt pilnu datumu t.i. viņš ieliek visu kas ir pirms komata, bet to kas ir pēc komata ne :( Kas tā varētu būt par vainu? P.S. Mēģināju arī ar atstarpi- nekā :( Link to comment Share on other sites More sharing options...
v3rb0 Posted March 23, 2006 Report Share Posted March 23, 2006 (edited) INSERT INTO `guestbook` (`name`,`email`,`message`,`date`) VALUES ('$name', '$email', '$message', now()); Edited March 23, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
KryPt0 Posted March 23, 2006 Author Report Share Posted March 23, 2006 Hmm... Ieliku "now()", bet viņš tā arī parāda iekšā datubāzē viņu kā "now()" mēģināju likt arī tā pat kā date, bet nekā... Iekš php.net arī neatrada funkciju "now" varbūt kaut ko esi sajaucis(stipri šaubos) vai arī vari paskaidrot tuvāk? Link to comment Share on other sites More sharing options...
bubu Posted March 23, 2006 Report Share Posted March 23, 2006 Kurš teica, ka tas jāliek kā "now()"? vai tad neredzi, ka v3rb0 uzrakstīja bez " pēdam?! Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 23, 2006 Report Share Posted March 23, 2006 pie now() izmantoshanas datu tipam jaabut DataTime... P.S. now() ir iebuuveetaa MySQL f-ja... tekoshaa datuma un laika ievietoshanai Link to comment Share on other sites More sharing options...
KryPt0 Posted March 23, 2006 Author Report Share Posted March 23, 2006 Kurš teica, ka tas jāliek kā "now()"? vai tad neredzi, ka v3rb0 uzrakstīja bez " pēdam?! es tās pēdiņas ieliku tiaki tekstā, lai izceltu funkciju :/ pie now() izmantoshanas datu tipam jaabut DataTime...P.S. now() ir iebuuveetaa MySQL f-ja... tekoshaa datuma un laika ievietoshanai Amm... Neko no šī nesapratu ;( Kas par DataTime ? Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 23, 2006 Report Share Posted March 23, 2006 KryPt0--> par SQL datu tipiem palasi... Link to comment Share on other sites More sharing options...
KryPt0 Posted March 23, 2006 Author Report Share Posted March 23, 2006 (edited) KryPt0--> par SQL datu tipiem palasi... Kur? o_0 EDIT: Atvainojos par šo debīlo jautājumu KUR :( Tas gan izskatās nikni gan ir nikni, bet vispār kļūda bija datubāzes uzbūvē :) Biju uzlicis CHAR=10 :/ Tas izsaka visu. Paldies anyway tiešām liels paldies :) Edited March 23, 2006 by KryPt0 Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 23, 2006 Report Share Posted March 23, 2006 KryPt0--> kaa bubu saka 'Isti viiri dokumentaaciju nelasa'.... rooc shet Link to comment Share on other sites More sharing options...
Recommended Posts