werd Posted January 11, 2008 Report Share Posted January 11, 2008 (edited) No DB nolasa vertibu 1 tad to nomaina uz 2 un izvada bet talak pec reresha neka!Kur kluda??? <?php $server="****"; $username="***"; $password="***"; $db="****"; $dbh = mysql_connect($server, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db($db) or die(mysql_error()); $result = mysql_query("SELECT * FROM counter"); while($row = mysql_fetch_array($result)) { echo "<span>" . $row['vertiba'] . "</span></br>"; } $row=$row +1; $row++; mysql_query("UPDATE counter SET vertiba='$row'") or die("kkas nav"); echo "nomainits"; $result = mysql_query("SELECT * FROM counter"); while($row = mysql_fetch_array($result)) { echo "<span>" . $row['vertiba'] . "</span></br>"; } ?> Edited January 11, 2008 by phpjanis Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 Ko nozīmē "nekā" ? Link to comment Share on other sites More sharing options...
werd Posted January 11, 2008 Author Report Share Posted January 11, 2008 (edited) "neka" ir domats ka pectam nietiek palielinata vertiba par vien! Edited January 11, 2008 by phpjanis Link to comment Share on other sites More sharing options...
Klez Posted January 11, 2008 Report Share Posted January 11, 2008 (edited) nomaini mysql_query("UPDATE counter SET vertiba='$row'") or die("kkas nav"); uz mysql_query("UPDATE counter SET vertiba='$row'") or die (mysql_error()); un skaties kas par kljuudu Edited January 11, 2008 by Klez Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 Bet vispār uzmetot otreiz aci uzreiz redzams, kur kļūda. Tev vērtība ir iekš $row['vertiba'], bet palielināt un ierakstīt DB tu mēģini $row (pašu masīvu). Link to comment Share on other sites More sharing options...
werd Posted January 11, 2008 Author Report Share Posted January 11, 2008 Nomainiju, tagad nerada pazinpjumus un nekadus errorus ari neuzmet! P.S #1 aizmirsu piebilst ka tas domats lapas apmekletaju skaitisanai(ja kads nesaprata uzreiz) Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 Parādi izmainīto kodu. Link to comment Share on other sites More sharing options...
werd Posted January 11, 2008 Author Report Share Posted January 11, 2008 (edited) <?php $server="****"; $username="***"; $password="***"; $db="****"; $dbh = mysql_connect($server, $username, $password) or die("Unable to connect to MySQL"); mysql_select_db($db) or die(mysql_error()); $result = mysql_query("SELECT * FROM counter"); while($row = mysql_fetch_array($result)) { echo "<span>" . $row['vertiba'] . "</span></br>"; } $row=$row +1; $row++; mysql_query("UPDATE counter SET vertiba='$row'") or die (mysql_error()); $result = mysql_query("SELECT * FROM counter"); while($row = mysql_fetch_array($result)) { echo "<span>" . $row['vertiba'] . "</span></br>"; } ?> Edited January 11, 2008 by phpjanis Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 Tu tak tikai mysql_error() esi pielicis. Šo izlasīji, ko iepriekš teicu ? Bet vispār uzmetot otreiz aci uzreiz redzams, kur kļūda. Tev vērtība ir iekš $row['vertiba'], bet palielināt un ierakstīt DB tu mēģini $row (pašu masīvu). Link to comment Share on other sites More sharing options...
werd Posted January 11, 2008 Author Report Share Posted January 11, 2008 (edited) Tu tak tikai mysql_error() esi pielicis. Šo izlasīji, ko iepriekš teicu ? Neiekeru ka editoji savu postu! Sank ka man janomaina $row=$row +1; $row++; uz $row['vertiba']=$row['vertiba'] +1; $row['vertiba']++; un ("UPDATE counter SET vertiba='$row['vertiba']'" ???? nedarbojas(mosh var kka savadak nolasito vertibu palielinat??) Edited January 11, 2008 by phpjanis Link to comment Share on other sites More sharing options...
mounkuls Posted January 11, 2008 Report Share Posted January 11, 2008 (edited) $result = mysql_query("SELECT * FROM counter");while($row = mysql_fetch_array($result)) { echo "<span>" . $row['vertiba'] . "</span></br>"; } kāda jēga no while, ja tabulā visdrīzāk ir viens ieraksts tikai. Un pareizi andrisp raksta ka mēģini palielināt masīvu ne countera vērtību tieši. Tavā gadijumā $row = mysql_fetch_array($result) -> $row[] būs ( $row['id'],$row['vertiba'],$row['time'] ) array ar vērtībām. Ja gribi palielināt tieši kolonnas `vertiba` vērtību, UPDATE `counter` SET vertiba='".($row['vertiba']+1)."'; Apmēram tā. Es jau nezinu kādas kolonnas un kā sauktas. Edited January 11, 2008 by mounkuls Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 (edited) A tu pamēģini! Bet vispār nesaprotu kāpēc, tu palielini to vērtību pa divi ? Un kveriju labāk: "UPDATE counter SET vertiba='{$row['vertiba']}'" mounkulis, reāli jau vispār viņam pietiktu ar šādu kodu :) mysql_query("UPDATE counter SET vertiba = vertiva + 1"); Edited January 11, 2008 by andrisp Link to comment Share on other sites More sharing options...
werd Posted January 11, 2008 Author Report Share Posted January 11, 2008 Ja tabula ir un visu laiku ari bus tikai viens ieraksts! Ka lai es vinu pie lapas atversanas palielinu visu laiku par viens!???? Link to comment Share on other sites More sharing options...
andrisp Posted January 11, 2008 Report Share Posted January 11, 2008 Tu lasīt nemāki ? Ir taču jau tev atbildēts. Link to comment Share on other sites More sharing options...
mounkuls Posted January 11, 2008 Report Share Posted January 11, 2008 Ja tabula ir un visu laiku ari bus tikai viens ieraksts!Ka lai es vinu pie lapas atversanas palielinu visu laiku par viens!???? Nestreb karstu:) Nekur nav zvanīts, ka negribēsi arī citām lapas sadaļām ieviest counter. Link to comment Share on other sites More sharing options...
Recommended Posts