Hack Forums
Column count doesn't match value count at row 1 [SOLVED] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: Column count doesn't match value count at row 1 [SOLVED] (/showthread.php?tid=5988723)



Column count doesn't match value count at row 1 [SOLVED] - Effexion - Jul 11, 2019

I am trying to make an app to help me trackk my tarantulas. I am getting the following error:

Quote:Column count doesn't match value count at row 1


I know this obviously means that I am trying to pass too many values into too few columns but I have counted, and recounted and no joy. My "id" column is AI so that shouldn't even come into play here.


PHP Code

<?php
function create(){
 
   global $connection;
 
   $genus = $_POST['genus'];
 
   $species = $_POST['species'];
 
   $lstFed = $_POST['lastFed'];
 
   $lstHouse = $_POST['rehousedOn'];
 
   $lstMolt = $_POST['lastMolt'];
 
   $temper = $_POST['temper'];
 
   $lstSub = $_POST['lstSub'];
 
   $query = "INSERT INTO spiders(genus, species, lastfed, lastrehouse, lastsub, temper, molt)"; $query .= "VALUES ('$genus', '$species', '$lstFed', '$lstHouse', '$lstSub,' '$temper', ";
 
   $query .="'$lstMolt')";
 
       
    $result 
= mysqli_query($connection, $query);
 
   if(!$result){
 
       die("<h1>FAILED TO ADD VALUE</h1>" . mysqli_error($connection));
 
   }
 
   else{
 
       echo "<h1>SPIDER ADDED TO THE DATABASE</h1>";
 
   }
}
?>

[Image: gsei0kN.png]

SOLVED:

[Image: fcTnpRx.png]


RE: Column count doesn't match value count at row 1 - SIM-574702 - Jul 11, 2019

Could you show value of query before you try to execute it, it would make debugging easier.


RE: Column count doesn't match value count at row 1 - Effexion - Jul 11, 2019

(Jul 11, 2019 09:04 AM)matemisic Wrote:  Could you show value of query before you try to execute it, it would make debugging easier.

At the risk of sounding like an idiot...what do you mean?