millers Posted May 6, 2008 Report Share Posted May 6, 2008 ko nozime si kluda Column count doesn't match value count at row 1 un kapec vinja man notika un ka es varu laboti so kludu rekur mans code no ka ta kluda radas .. http://paste.php.lv/7308 rekur mana mysql tabula CREATE TABLE `lietotaji` ( `id` smallint(30) NOT NULL, `levels` varchar(5) NOT NULL, `logins` varchar(17) NOT NULL, `parole` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ta viss notika sekojosi (apraksts no ka izcelas errors) taatad taa es uztaisiju tabutu so pasu kur uzradu tikai vell levels colum viss gaja perfekti viss insertojas utt pievienoju colum levels uzmetas sis errors ...kur vaina ? man liekas kad php code bet isti nezinu ... Column count doesn't match value count at row 1 Link to comment Share on other sites More sharing options...
andrisp Posted May 6, 2008 Report Share Posted May 6, 2008 ...INTO lietotaji value (.. http://www.google.com/search?hl=en&q=sql+tutorial http://www.w3schools.com/sql/sql_insert.asp Link to comment Share on other sites More sharing options...
Faks Posted May 6, 2008 Report Share Posted May 6, 2008 mysql kodejums skibs te teu bus ejos ! /* MySQL Data Transfer Source Host: localhost Source Database: lietotaji Target Host: localhost Target Database: lietotaji Date: 2008.05.06. 11:26:09 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for lietotaji -- ---------------------------- DROP TABLE IF EXISTS `lietotaji`; CREATE TABLE `lietotaji` ( `id` int(11) NOT NULL auto_increment, `levels` varchar(5) NOT NULL, `logins` varchar(17) NOT NULL, `parole` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records -- ---------------------------- Link to comment Share on other sites More sharing options...
andrisp Posted May 6, 2008 Report Share Posted May 6, 2008 Atkal Faks muld kaut ko pilnīgu nesaistītu... Link to comment Share on other sites More sharing options...
marz Posted May 6, 2008 Report Share Posted May 6, 2008 mysql_query("INSERT INTO lietotaji value ('0', '".$_POST['logins']."', '".$_POST['parole']."')") Tev ir DB ar 4 tabulām, bet iekš DB tu ievieto tikai trīs, tas varētu būt iemesls kļūdai. Link to comment Share on other sites More sharing options...
bubu Posted May 6, 2008 Report Share Posted May 6, 2008 marz: gadījumā nejauc tabulas ar laukiem? Link to comment Share on other sites More sharing options...
kasisppr Posted May 6, 2008 Report Share Posted May 6, 2008 Nu lūk, dzīvs piemērs, kāpēc dažreiz labāk izmantot INSERT INTO table (col1, col2, ...) VALUE (col1_value, col2_value, ....); nevis INSERT INTO table (col1_value, col2_value, ....); Pirmajā gadījumā pastāv iespēja, ka kods nav jāmaina, ja pieliec papildus kolonas, taču otrā bez izmaiņām kverijā neiztiksi. Link to comment Share on other sites More sharing options...
bubu Posted May 6, 2008 Report Share Posted May 6, 2008 Ne vienmēr vajag insertot visas vērtības, citreiz defaultās ir jāatstāj. Daudz labāk ir uzrakstīt mazu wraperīti: function insert($table, $data) { return "INSERT INTO $table (" . implode(",", array_keys($data)) . ") VALUES (" . implode(",", array_values($data)) . ")"; } mysql_query(insert("tabula", array("lauks1" => "asdf", "lauks2" => "zumm"))); Šajā gadījumā itin viegli būs ielikt arī automātisku datu eskeipošanu - vajadzēs tik vienu funkciju pamainīt. Link to comment Share on other sites More sharing options...
marz Posted May 9, 2008 Report Share Posted May 9, 2008 bubu: jā, my bad, sajaucu. bet ideju jau saprati Link to comment Share on other sites More sharing options...
Recommended Posts