Klez Posted February 16, 2005 Report Share Posted February 16, 2005 funkcija ar kuru var ievietot tabulaa kaut ko. nav svariigi cik lauki ir tabulaa, vaig tikai veertiibas padot. Normāli uzrakstiita, vai galiigi garaam? function addComment($values,$table,$commAddedSucc){ /* example: addComment("'$id' ~ '$val1' ~ '$val2' ~ '".$val3."' ~ '$val4' ~ '".$val5."'", $tabula, "Koments veiksmiigi pievienots"); */ $values = explode("~",$values); $cikVal = count($values); $value = ''; for ($i=0;$i<=$cikVal;$i++){ $value .= "".$values[$i].","; } $value = trim($value); $value = substr($value,0,-2); //nonjemam peedeejo komatu $q = "INSERT INTO $table VALUES($value)"; mysql_query($q) or print("addComment() SQL error:<br>".mysql_error()); unset($values,$value,$q); echo $commAddedSucc; } Link to comment Share on other sites More sharing options...
Venom Posted February 16, 2005 Report Share Posted February 16, 2005 es ierakstu kādā value-ā "~", vai " ' " zīmi Link to comment Share on other sites More sharing options...
Klez Posted February 17, 2005 Author Report Share Posted February 17, 2005 (edited) pirms shiis funkcijas tik texti izlaisti caur shito f-ciju: function char2simb($myHTML) { $mas = array( "'" => "'", //shiten ir paredzeets &_#39; bez _ "\"" => """, "<" => "<", ">" => ">", "`" => "`", "~" => "~", '"' => """ ); return nl2br(strtr($myHTML,$mas)); } te visu raada kaa ir; paskatoties view source tad tur ' ~ ir kaa simboli :) Edited February 17, 2005 by Klez Link to comment Share on other sites More sharing options...
bubu Posted February 17, 2005 Report Share Posted February 17, 2005 (edited) 1) ' un " pārveidot vajag par ' un " nevis kautkādiem #... 2) kāda jēga "`" => "`" un "~" => "~" ??? 3) un vispār - labāk tak izmantot htmlspecialchars() fju :) edit: ahā sapratu 2) :) nevajag ņemt to vērā. Edited February 17, 2005 by bubu Link to comment Share on other sites More sharing options...
Roze Posted February 17, 2005 Report Share Posted February 17, 2005 Vispār jau šādi manuprāt ir daļēji garām.. $q = "INSERT INTO $table VALUES($value)"; jo kverijs izveidosies pareizs tikai tad ja padoto vērtību skaits sakritīs ar tabulas lauku skaitu, kas savukārt nozīmē ka vienmēr jāseko visam līdz (skaitam un secībai) un arī autoincrementālajos laukus jāpadod vērtība '' Pēc manām domām prātīgāk būtu funkcijai padod asociatīvu masīvu kur keyi ir lauku nosaukumi un tad kveriju veidot ar INSERT INTO $table SET $key1 = '$value1', $key2 = $value2 vai arii INSERT INTO $table ($key1,$key2) VALUES ('$val1','$val2'); Piemēram: function blabla($m,$table) { mysql_query("INSERT INTO $table ('".implode("','",array_keys($m))."') VALUES ('".implode("','",$m)."')"); } un tad blabla(array('lauks1'=>'vertiba1','lauks2'=>'vertiba2'),'tabula'); protams $values der arii esceipot ar mysql_escape_string() p.s. ja gribās lāpit slinkumu tad jau pašas postojamās formas elementus var nosaukt pareizajos nosaukumos. <input type="text" name="frm[nick]"> <input type="text" name="frm"> un tad padot tikai blabla($frm,$tablje) vai $_POST[frm] .. Link to comment Share on other sites More sharing options...
Klez Posted February 18, 2005 Author Report Share Posted February 18, 2005 1) ' un " pārveidot vajag par ' un " nevis kautkādiem #... 13858[/snapback] taadu ' nezinu. nekur neatradu. IE arii taadu nepaziit. ka tik tu nau izdomaajis savu simbolu ;) rozes variants arii nau slikts. bet es autoincrement padodu tuxumu un jams nebljaustaas - viss straadaa :) Link to comment Share on other sites More sharing options...
bubu Posted February 18, 2005 Report Share Posted February 18, 2005 taadu ' nezinu. nekur neatradu. IE arii taadu nepaziit. ka tik tu nau izdomaajis savu simbolu ;) Ui, laikam to paņēmu no XHTML nevis HTML: http://www.validome.org/lang/en/html/resou...tml-special.ent :)) Link to comment Share on other sites More sharing options...
Klez Posted February 18, 2005 Author Report Share Posted February 18, 2005 te var paluureet HTML kodinjus. ir arii ar alternatiivaam Link to comment Share on other sites More sharing options...
bubu Posted February 18, 2005 Report Share Posted February 18, 2005 te var paluureet HTML kodinjus. ir arii ar alternatiivaam 13884[/snapback] Nu un pēc kāda standarta tas ir? Es labāk tādas lapas neizmantoju, nav garantijas nekādas no kurienes tas ņemts. Es labāk izmantoju w3 specifikācijas vai šo lapu: http://www.validome.org/lang/en/html/resources/ (tur ir arī visas oficiālās entītes). Link to comment Share on other sites More sharing options...
Recommended Posts