<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Aiuto codice Column count doesn't match value count at row 1]]></title><description><![CDATA[<p dir="auto">Salve a tutti,<br />
è da giorni che sto litigando con questo codice php per l'inserimento dei dati in un database mysql. Mi potete aiutare? Grazie<br />
L'errore che ricevo è che al momento di premere salva mi esce questo: Column count doesn't match value count at row 1</p>
<pre><code>&lt;form method="post" action=""&gt;
&lt;?php
$campo=array();
$campo[]=array("type"=&gt;"text","nome"=&gt;"username");
$campo[]=array("type"=&gt;"text","nome"=&gt;"data");
$campo[]=array("type"=&gt;"text","nome"=&gt;"ora");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo1");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo2");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo3");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo4");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo5");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo6");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo7");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo8");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo9");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo10");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo11");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo12");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo13");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo14");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo15");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo16");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo17");
$campo[]=array("type"=&gt;"text","nome"=&gt;"puntiatt");
$campo[]=array("type"=&gt;"text","nome"=&gt;"puntiottenuti");

foreach($campo as $k =&gt; $v){
    switch($v['type']){
        case "text":
            echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="text" name="' . $v['nome'] . '" /&gt;&lt;br/&gt;';
        break;
        case "bool":
            echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="checkbox" name="' . $v['nome'] . '" value="1" /&gt;&lt;br/&gt;';
        break;
        default:
            echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="text" name="' . $v['nome'] . '" /&gt;&lt;br/&gt;';
        break;
    }
}

if(isset($_POST)){
     $server="****";
     $user="***";
     $pass="***"; 
     $db="**";
     $tabella="punti";
     $link=mysql_connect($server,$user,$pass)or die(mysql_error());
     $sel_db=mysql_select_db($db,$link)or die(mysql_error());
     $query="INSERT INTO $tabella VALUES(";
     $i=0;
     foreach($_POST as $k =&gt; $v){
          $v=htmlspecialchars($v);
          if($i==0){
              $query.="'" . $v . "'";
          }else{
              $query.=",'" . $v . "'";
          }
          $i++;
     }
     $query.=")";
     $exec=mysql_query($query,$link)or die(mysql_error());
     mysql_close($link);
     
}
?&gt;
&lt;input type="submit" value="Salva" /&gt;
&lt;/form&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/113272/aiuto-codice-column-count-doesn-t-match-value-count-at-row-1</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 05:05:48 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/113272.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Oct 2009 17:06:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Mon, 26 Oct 2009 05:55:55 GMT]]></title><description><![CDATA[<p dir="auto">Se usi phpmyadmin ti basta accedere al tuo database e vedere la struttura della tabella 'punti'.</p>
<p dir="auto">Per una migliore flessibilità ti consiglio anch'io di utilizzare i nomi dei campi invece che riempire ordinatamente tutti i campi, tuttavia ciò non è indispensabile, e se ti fai una lista ordinata dei campi della tabella ti basta anche solo inserire i valori alle rispettive posizioni.</p>
]]></description><link>https://dev.connect.gt/post/865842</link><guid isPermaLink="true">https://dev.connect.gt/post/865842</guid><dc:creator><![CDATA[pater]]></dc:creator><pubDate>Mon, 26 Oct 2009 05:55:55 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 19:08:13 GMT]]></title><description><![CDATA[<p dir="auto">Dovresti postare la struttura della tabella.<br />
Senza quella non posso aiutarti più di cosi.</p>
]]></description><link>https://dev.connect.gt/post/865847</link><guid isPermaLink="true">https://dev.connect.gt/post/865847</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sun, 25 Oct 2009 19:08:13 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 18:05:13 GMT]]></title><description><![CDATA[<p dir="auto">Scusa ma il php mi è nuovo <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":-)" alt="🙂" /> se riesci ed hai voglia visto che il mio assistente sara' assente per un po se riesci postarmi la query modificata mi faresti un grandissimo favore</p>
]]></description><link>https://dev.connect.gt/post/865857</link><guid isPermaLink="true">https://dev.connect.gt/post/865857</guid><dc:creator><![CDATA[webmatsolution]]></dc:creator><pubDate>Sun, 25 Oct 2009 18:05:13 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:40:15 GMT]]></title><description><![CDATA[<p dir="auto">Il values va bene così com'è, devi modificare la query in modo da essere come quella che ti ho postato io, perchè sicuramente hai invertito l'ordine di qualche campo non essendo specificati e quindi ottieni quell'errore.</p>
]]></description><link>https://dev.connect.gt/post/865846</link><guid isPermaLink="true">https://dev.connect.gt/post/865846</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:40:15 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:37:54 GMT]]></title><description><![CDATA[<p dir="auto">Non ho ben capito cosa mettere in values. cioè non ho gia i campi</p>
]]></description><link>https://dev.connect.gt/post/865859</link><guid isPermaLink="true">https://dev.connect.gt/post/865859</guid><dc:creator><![CDATA[webmatsolution]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:37:54 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:32:57 GMT]]></title><description><![CDATA[<p dir="auto">Bisognerebbe vedere la struttura della tabella.<br />
Conviene comunque strutturare la query in modo da specificare il value a quale campo si riferisce, sicuramente qualche campo è invertito rispetto alla struttura della tabella.<br />
Un esempio pratico di come dovrebbe venire è:</p>
<pre><code>INSERT INTO punti(nome, data, ora, campo1, campo2 ,campo3) VALUES('matteo','23/09/2009','12.34','1','12','32')
</code></pre>
]]></description><link>https://dev.connect.gt/post/865845</link><guid isPermaLink="true">https://dev.connect.gt/post/865845</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:32:57 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:30:23 GMT]]></title><description><![CDATA[<p dir="auto">Grazie 1000 molto gentile per il codice.<br />
ho inserito facendo questa prova:<br />
username ho messo matteo<br />
data ho messo 23/09/2009<br />
ora ho messo 12.32<br />
ed ho selezionato il primo campo</p>
<p dir="auto">il risultato è questo</p>
<pre><code>INSERT INTO punti VALUES('matteo','23/09/2009','12.34','1','12','32')Column count doesn't match value count at row 1
</code></pre>
]]></description><link>https://dev.connect.gt/post/865861</link><guid isPermaLink="true">https://dev.connect.gt/post/865861</guid><dc:creator><![CDATA[webmatsolution]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:30:23 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:20:35 GMT]]></title><description><![CDATA[<pre><code class="language-php">&lt;form method="post" action=""&gt;
&lt;?php
$campo=array();
$campo[]=array("type"=&gt;"text","nome"=&gt;"username");
$campo[]=array("type"=&gt;"text","nome"=&gt;"data");
$campo[]=array("type"=&gt;"text","nome"=&gt;"ora");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo1");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo2");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo3");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo4");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo5");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo6");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo7");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo8");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo9");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo10");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo11");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo12");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo13");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo14");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo15");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo16");
$campo[]=array("type"=&gt;"bool","nome"=&gt;"campo17");
$campo[]=array("type"=&gt;"text","nome"=&gt;"puntiatt");
$campo[]=array("type"=&gt;"text","nome"=&gt;"puntiottenuti");

foreach($campo as $k =&gt; $v){
    switch($v['type']){
        case "text":
             echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="text" name="' . $v['nome'] . '" /&gt;&lt;br/&gt;';
        break;
        case "bool":
             echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="checkbox" name="' . $v['nome'] . '" value="1" /&gt;&lt;br/&gt;';
        break;
        default:
             echo '&lt;b&gt;' . $v['nome'] . ':&lt;/b&gt;&lt;input type="text" name="' . $v['nome'] . '" /&gt;&lt;br/&gt;';
        break;
    }
}

if(isset($_POST)){
     $server="****";
     $user="***";
     $pass="***"; 
     $db="**";
     $tabella="punti";
     $link=mysql_connect($server,$user,$pass)or die(mysql_error());
     $sel_db=mysql_select_db($db,$link)or die(mysql_error());
     $query="INSERT INTO $tabella VALUES(";
     $i=0;
     foreach($_POST as $k =&gt; $v){
          $v=htmlspecialchars($v);
          if($i==0){
              $query.="'" . $v . "'";
          }else{
              $query.=",'" . $v . "'";
          }
          $i++;
     }
     $query.=")";
echo 
$query;
     $exec=mysql_query($query,$link)or die(mysql_error());
      mysql_close($link);
     
}
?&gt;
&lt;input type="submit" value="Salva" /&gt;
&lt;/form&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/865844</link><guid isPermaLink="true">https://dev.connect.gt/post/865844</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:20:35 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:17:47 GMT]]></title><description><![CDATA[<p dir="auto">Saresti cosi gentile da postarmi il codice?</p>
<p dir="auto">Grazie</p>
]]></description><link>https://dev.connect.gt/post/865858</link><guid isPermaLink="true">https://dev.connect.gt/post/865858</guid><dc:creator><![CDATA[webmatsolution]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to Aiuto codice Column count doesn't match value count at row 1 on Sun, 25 Oct 2009 17:09:15 GMT]]></title><description><![CDATA[<p dir="auto">Ciao webmatsolution,</p>
<p dir="auto">fai un echo della query, e prova a vedere cosa va ad eseguire.</p>
]]></description><link>https://dev.connect.gt/post/865843</link><guid isPermaLink="true">https://dev.connect.gt/post/865843</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sun, 25 Oct 2009 17:09:15 GMT</pubDate></item></channel></rss>