doutuan4361 2018-12-03 04:11
浏览 65

PHP到SQL DB插入,不断收到错误“列数与第1行的值计数不匹配”[重复]

I am trying to get some information to insert into my SQL database using PHP. However, I keep getting that error when trying to do the insert. I have counted and made sure that the data types are correct in my database. I have also counted to make sure nothing extra is being inserted. I cannot seem to figure out how to get this data inserted into my database. Here is the full error message:

mysqli Object ( [affected_rows] => 0 [client_info] => 5.5.42 [client_version] => 50542 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.5.60 [server_version] => 50560 [stat] => Uptime: 2086072 Threads: 1 Questions: 1110 Slow queries: 0 Opens: 77 Flush tables: 1 Open tables: 55 Queries per second avg: 0.000 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 9123 [warning_count] => 0 ) Inserting Here Whole query INSERT INTO Library.userdatabase (idFriendAndFamily, password, firstname, lastname,phonenumber, address, city, state, zip, birthdate, username, sex, relationship) VALUES('test, bob, saget, 2342134, fakestreet, fakeland,state, 12345, 1234, test, male, friend') Invalid query: Column count doesn't match value count at row 1

Here is the code I am using to insert with PHP:

 switch ($action)
    {
            case "insert":
                echo "Inserting Here ";
                $insert = "INSERT INTO `Library`.`userdatabase` (`idFriendAndFamily`, `password`, `firstname`, `lastname`,"
            ."`phonenumber`, `address`, `city`, `state`, "
            ."`zip`, `birthdate`, `username`, `sex`, `relationship`) VALUES('$password', '$firstname', "
            ."$'lastname', '$phonenumber', '$address', '$city',"
            ."'$state', '$zip', '$birthdate', '$username', '$sex', '$relationship')"; //'N'

            $success = $con->query($insert);

            if($success == FALSE)
            {
                $failmess = "Whole query " . $insert . "<br>";
                echo $failmess;
                die('Invalid query: ' . mysqli_error($con));
            } else
            {
                echo "$insertArray was added <br>";
            }
            break;

Can anyone see what is going wrong? I have racked my brain over this trying everything I can think of, so any help is appreciated!

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向