column count doesn't match the value count at row 1_database insert error

February 11, 2019, at 08:30 AM

Been working on this for a while. For some reason even though I have enough values and columns, I get "column count doesn't match value count at row 1" error.

I tried passing $values as array-- doesn't work because its array. Tried putting $values and $kk inside '', but didn't work. This version of code yielded least amount of errors.


    $dbh = new mysqli("localhost", "admin", "password", "database");
    $dta= mysqli_query($dbh,"SELECT * FROM agents");
    $agntProperties = new agntObjects;
    $ary = array ($agntProperties->agntID=$_GET['id'] => array(
    $agntProperties->agntFName=$_GET['fname'],//error occurs"unknown column in field list
    $agntProperties->agntLastname = $_GET['lname'],
    $agntProperties->agntBusPhone = $_GET['agntbusphone'],
    $agntProperties->agntEmail = $_GET['email'],
    $agntProperties->agntPosition = $_GET['agntpos'],
    $agntProperties->agencyId = $_GET['agencyId']));
    $arryy = array ((int)$_GET['id'],$_GET['fname'],$_GET['mname'],$_GET['lname'],

function insertDta(array $agntArray, $database, $table)
    $agntProperties = $GLOBALS['agntProperties'];
    $database=$GLOBALS['dbh'];//it should be something that changes depending on agent

    $agntdata= get_class($agntProperties)::$fields; // $fields properties are below for reference
    //public static $fields = array ('AgentId','AgtFirstName', 'AgtMiddleInitial', 'AgtLastName','AgtBusPhone','AgtEmail', 'AgtPosition','AgencytId')
    $agntprops= implode(',', $agntdata);
    $vals= array();
    foreach($agntArray as $k=>$v)
        $vals= $v;        
    $values= implode(',',$vals);

    $sql = "INSERT INTO agents ($agntprops) VALUES ($kk,'$values')";

    $result= mysqli_query($database,$sql);
        echo "all good";
    }else {
        echo "update failed"."<br>";
        echo  mysqli_error($database);


    insertDta($ary,"", "");
    $dbh-> close();


Expected results would be: being able to insert all the values such as agentid, firstname, etc to database.

cannot get id from ajax

cannot get id from ajax

I can't get the id from the js file, I don't know if the js code or the php code is wrongCan someone help? problem seems to be from index

Inserting 2 rows instead of one: angular and php

Inserting 2 rows instead of one: angular and php

I am working with angular 6 and phpWhen i add an entity whith my application, i find that the backend is inserting 2 rows in the table instead of one

Merge dataframes by left join SQL &amp; Pandas

Merge dataframes by left join SQL & Pandas

I made two tables into a MySQL database using PythonThe following SQL code is to perform join on two tables in the database