Mikijs Posted February 21, 2008 Report Share Posted February 21, 2008 (edited) Rekur mans SQL viegli parskatama veida $fails="..."; $a_fails="...."; $love_fails="...."; $vards=htmlspecialchars($_POST['vards']); $love_vards=htmlspecialchars($_POST['love_vards']); $uzvards=htmlspecialchars($_POST['uzvards']); $love_uzvards=htmlspecialchars($_POST['love_uzvards']); $vardins=htmlspecialchars($_POST['vardins']); $love_vardins=htmlspecialchars($_POST['love_vardins']); $kopa_a=$_POST['kopa_a']; $kopa_b=$_POST['kopa_b']; $kopa_c=$_POST['kopa_c']; $parmums=$_POST['parmums']; $login=htmlspecialchars($_POST['login']); $parole=md5($_POST['parole']); $registrejas=date("Y/m/d"); $regip = $_SERVER['REMOTE_ADDR']; //Ievietojam datubaze informaciju dbquery("INSERT INTO ".PREF."lietotaji (vards, uzvards, parmums, vardins, love_vards, love_uzvards, love_vardins, a_bilde, love_bilde, bilde, kopa_a, kopa_b, kopa_c, login, parole, online, balsis, balsotaja_datums, registrejas, love_vardins, balsotaja_ip, reg_ip) VALUES('$vards', '$uzvards', '$parmums' '$vardins', '$love_vards', '$love_uzvards', '$love_vardins', '$a_fails', '$love_fails', '$fails', '$kopa_a', '$kopa_b', '$kopa_c', '$login', '$parole', '0', '0', '0', '$registrejas', '$love_vardins', '0', '$regip')"); Tagad lugums jums pateikt kas ir nepareizi :) davai davai ;) - nepareizi: Column count doesn't match value count at row 1 bet es izskaitu man ir 19 kolonas un 19 valjues.. Edited February 21, 2008 by Mikijs Link to comment Share on other sites More sharing options...
bubu Posted February 21, 2008 Report Share Posted February 21, 2008 Dīvaini skaitīji. Man gan sanāk 22 gabali. Anyway - tas NAV pārskatāms veids. Pārskatāms būtu šāds veids: $data = array("vards" => $vards, "uzvards" => $uzvards, "parmums" => $parmums, //... "balsotaja_ip" => "0", "reg_ip" => $regip); $keys = implode(",", array_keys($data)); $values = array(); foreach($data as $value) { $values[] = "'$value'"; } $values = implode(',', $values); $query = "INSERT INTO " . PREF . "lietotaji ($keys) VALUES ($values)"; Un vēl - $_POST/$_GET datus NEDRĪKST likt pa tiešo kverijā. Tie ir jāeskeipo pret sliktajiem simboliem, piemēram, ar mysql_escape_string. Citādi tavu DB "uzlauzt" būs kā tikpat viegli kā pārspļaut pār lūpu. Link to comment Share on other sites More sharing options...
Mikijs Posted February 21, 2008 Author Report Share Posted February 21, 2008 nu man ta ir viena gara rinda es te vienkarsi katru sava rinda ieliku, bet man rada to tekstu Link to comment Share on other sites More sharing options...
Mikijs Posted February 21, 2008 Author Report Share Posted February 21, 2008 mnjus es izdzesu visu qveriju un sarakstiju pa jaunu un aizgaja bet nesaprotu kur ta vaina bija... ok pldies ta pat.. Link to comment Share on other sites More sharing options...
Roze Posted February 21, 2008 Report Share Posted February 21, 2008 Šitiem vājprātigajiem insertiem vienkāršāk ir lietot citu sintaksi.. nevis INSERT INTO table (field1,field2, ..... . .. .. ) VALUES (val1,val2, ..... ), bet gan INSERT INTO table SET field1 = 'value1', field2 = 'value2' , ...., field19 = 'value19'; var sakārtot arī: INSERT INTO table SET field1 = 'value1', field2 = 'value2', ...., field19 = 'value19'; Link to comment Share on other sites More sharing options...
Mikijs Posted February 21, 2008 Author Report Share Posted February 21, 2008 ok =] paldies Roze ;) man vienmer likas ka SET... tikai uz UPDATE :d Link to comment Share on other sites More sharing options...
mixis Posted February 22, 2008 Report Share Posted February 22, 2008 kalēc love_vardins ir divreiz? Link to comment Share on other sites More sharing options...
xPtv45z Posted February 22, 2008 Report Share Posted February 22, 2008 Kļūda bija tāpēc, ka aiz '$parmums' trūkst komata. Link to comment Share on other sites More sharing options...
GedroX Posted February 22, 2008 Report Share Posted February 22, 2008 INSERT INTO ... SET nav gluži SQL standarts. :) Link to comment Share on other sites More sharing options...
andrisp Posted February 22, 2008 Report Share Posted February 22, 2008 Bet nu ja MySQL to piedāvā, kāpēc neizmantot ? :) Link to comment Share on other sites More sharing options...
GedroX Posted February 22, 2008 Report Share Posted February 22, 2008 Vieni seko standartiem, citi nē. Domāju, ka nav jēgas stāstīt, kāds labums ir sekot standartiem. Link to comment Share on other sites More sharing options...
andrisp Posted February 22, 2008 Report Share Posted February 22, 2008 (edited) Varbūt tomēr pastāsti tieši kāds labums būtu šajā konkrētajā gadijumā ? Vienīgais, ko es varu iedomāties - ja nāktos pārnest sistēmu no mysql uz kaut ko citu, tad jā, potenciāli būtu mazāk darba. PS. Un man liekas, ka MySQL jau vispār ir pilns (tāpat arī jebkura cita db sistēma) ar dažādām nestandarta fiškām, ko visi izmanto, pat nezinot, ka tā ir nestandarta. Iespējams, arī tu. Edited February 22, 2008 by andrisp Link to comment Share on other sites More sharing options...
GedroX Posted February 22, 2008 Report Share Posted February 22, 2008 Es uz pgsql. MySQL pēc PostgreSQL izskatās smieklīgi. Vismaz MySQL4. Link to comment Share on other sites More sharing options...
andrisp Posted February 22, 2008 Report Share Posted February 22, 2008 GedroX, ko tu gribēji tikko pateikt ? :) Link to comment Share on other sites More sharing options...
bubu Posted February 22, 2008 Report Share Posted February 22, 2008 To, ka MySQL sux, un PgSQL rullz. Link to comment Share on other sites More sharing options...
Recommended Posts