martins256 Posted March 21, 2006 Report Share Posted March 21, 2006 (edited) Tātad šim kodam vajag pievienot datu baazei jaunus vārdus(angliski), ja šis vārds eksistē, tad pie latviski pievienot klāt vēl. Diemžēl netieku tālāk par salīdzināšanu... <?php require($_SERVER["DOCUMENT_ROOT"]."/konfiguraacijas.php"); $connection = @mysql_connect($db_host, $db_user, $db_password) or die("Kļūda pieslēdzoties MySQL"); mysql_select_db($db_name, $connection); //nolasa submitotos vardus $latviski = @$_POST["latviski"]; $garums = strlen($latviski); $angliski = @$_POST["angliski"]; $ngarums = strlen($angliski); //nosaka, vair ir kaut kas pievienots if (($garums > 1) && $ngarums > 1) { //te saakaas probleemas $query = "select * from tulkot where angliski= '$angliski'"; $result = mysql_query($query, $connection); $vaards = mysql_result($result, 0, "angliski"); //pivieno beigaas, shitam jaabuut tad, ja nesakriit $query = "insert into tulkot (angliski, latviski) values ('$angliski','$latviski')"; mysql_query($query, $connection) or die(mysql_error()); } //pievienoshana ?> <td> <center> <form action="taisiit.php?id=<? echo $id;?>" method="POST"> <input type="text" name="angliski" size="15"> <br> <textarea style="width:70%" rows="5" name="latviski"></textarea><br> <center><input type="submit" value="Pievienot"></center> </form> </center> </td> Edited March 21, 2006 by martins256 Link to comment Share on other sites More sharing options...
v3rb0 Posted March 21, 2006 Report Share Posted March 21, 2006 šitais man nepatīk: $vaards mysql_result($result, 0, "angliski"); Link to comment Share on other sites More sharing options...
martins256 Posted March 21, 2006 Author Report Share Posted March 21, 2006 nu to izlaboju, bet vienalga sanjemu error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in C:\web\www\taisiit.php on line 21 tas ir deelj taa, ka vins nav atradis taadu vaardu tabulaa, un vinam nav ko tam dod, bet man vajag kaut kaa apiet sho probleemu Link to comment Share on other sites More sharing options...
v3rb0 Posted March 21, 2006 Report Share Posted March 21, 2006 "select count(*) as cnt from tulkot where angliski= '$angliski'" un skaties cik ir cnt ? Link to comment Share on other sites More sharing options...
martins256 Posted March 21, 2006 Author Report Share Posted March 21, 2006 "select count(*) as cnt from tulkot where angliski= '$angliski'" un skaties cik ir cnt ? sanaak, ka vins ir ielikts ieks $cnt ?, ko tas count(*) noziimee ? Un kā var dabūt krāsainu code? P.S. es php tik sāku apgūt, tāpēc nesmejaties par muļķīgiem jautājumiem Link to comment Share on other sites More sharing options...
Delfins Posted March 23, 2006 Report Share Posted March 23, 2006 nu tak apgūsti! Lasi grāmatas un manuāļus.. visas atbildes uz taviem jautājumiem tur 100% ir!!! Link to comment Share on other sites More sharing options...
SkyD Posted March 23, 2006 Report Share Posted March 23, 2006 $cnt ir parametrs pēc kura tiek saskaitīti tie anglju vārdi. Un tad ar to var pārbaudīt vai tāds ir, vai nav. Link to comment Share on other sites More sharing options...
Recommended Posts