ziedinjsh Posted October 7, 2011 Report Share Posted October 7, 2011 Sveiki! Es īsti nesaprotu kapēc man nenostrādā update: $id = (isset($_GET['id'])) ? $_GET['id'] : ''; $data = mysql_fetch_array(mysql_query("SELECT * FROM articles WHERE id='$id'")) or die(mysql_error()); $addviews = mysql_query("UPDATE articles SET views=views+1 WHERE id='$id'"); $title = $data['title']; if(strlen($title) > 90) $title = substr($title, 0, 90).'...'; if(isset($_POST['like'])){ mysql_query("UPDATE articles SET like=like+1 WHERE id='$id'"); } echo " <div id='fullview' style='overflow:hidden;'> <div class='title'>".$title."</div> <div class='article'><div class='articlein'>".$data['article']."</div></div> <div class=''> <form method='post' action='".$_SERVER['PHP_SELF']."?s=read&id=".$id."'> <input type='submit' name='like' value='patīk ".$data['like']."'> </form> </div> </div> "; Šis strādā $addviews = mysql_query("UPDATE articles SET views=views+1 WHERE id='$id'"); bet otrais kas ir isset tas neapdeito! Kapēc tā? vai tad divi update nevar būt vienā lapā? Link to comment Share on other sites More sharing options...
nikidijs Posted October 7, 2011 Report Share Posted October 7, 2011 (edited) Var jau gan laikam būt divi UPDEIT vienā lapā. Bet... moš noprovē šitādu brīnumu if(isset($_POST['like'])) { $set="views=views+1, like=like+1"; } else { $set="views=views+1"; } $addviews = mysql_query("UPDATE articles SET ".$set." WHERE id='$id'"); Ko šis tad saka ? Edited October 7, 2011 by nikidijs Link to comment Share on other sites More sharing options...
andism88 Posted October 7, 2011 Report Share Posted October 7, 2011 (edited) Datubāzē viss ir ok? nomaini mysql_query pret echo un izvadīto tekstu ievadi teiksim phpmyadmin.... Edited October 7, 2011 by andism88 Link to comment Share on other sites More sharing options...
mounkuls Posted October 8, 2011 Report Share Posted October 8, 2011 Vienkārši LIKE skaitās rezervēts vārds, tā es domāju vismaz. Lieto `like`. Lai gan es iesaku vispār lauka nosaukumu nomainīt uz ko citu. Link to comment Share on other sites More sharing options...
codez Posted October 8, 2011 Report Share Posted October 8, 2011 Ja jau raksta pareizi angliski daudzskaitlī, tad tā arī raksta - views, likes, etc. Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 8, 2011 Author Report Share Posted October 8, 2011 Vienkārši LIKE skaitās rezervēts vārds, tā es domāju vismaz. Lieto `like`. Lai gan es iesaku vispār lauka nosaukumu nomainīt uz ko citu. Jap.. tas arī bija pie vainas.. nomainīju uz likes un viss strādā Link to comment Share on other sites More sharing options...
Recommended Posts