Error Column count doesn't match value count a

2019-03-03 18:31发布

where is error..... Column count doesn't match value count at row 1

mysqli_select_db($conn, $data);
    $save = "INSERT INTO SONG_AS(ALBUM, CATEGORY, SUB_CATEGORY,
        SONG_NAME, ARTIST, ART_LINK, 
        YEAR, GENRE, SONG_LINK, POST_ON, 
        POST_BY, TOTAL_DOWNLOAD) 
            VALUES('$albm', '$cat', '$scat', "
            . "'$sn', '$art', '$img', "
            . "'$y', '$g', "
            . "'$sl', '$time', '', '0')";


    $success = mysqli_query($conn, $save) or die(mysqli_error($conn));
    $page = "index.php";
    $this->pageRedirect($page);

where is error..... Column count doesn't match value count at row 1

标签: php mysqli
3条回答
欢心
2楼-- · 2019-03-03 18:56

Try this:

$save = "INSERT INTO SONG_AS(`ALBUM`, `CATEGORY`, `SUB_CATEGORY`,
                    `SONG_NAME`, `ARTIST`, `ART_LINK`, 
                    `YEAR`, `GENRE`, `SONG_LINK`, `POST_ON`, 
                `POST_BY`, `TOTAL_DOWNLOAD`) 
        VALUES('".$albm."', '".$cat."', '".$scat."','".$sn."', '".$art."', '".$img."', '".$y."', '".$g."', '".$sl."', '".$time."', '', '0')";
查看更多
做个烂人
3楼-- · 2019-03-03 18:59
 $query = "INSERT INTO employee VALUES ($empno','$lname','$fname','$init','$gender','$bdate','$dept','$position','$pay','$dayswork','$otrate','$othrs','$allow','$advancesance,'')";
    $msg = "New record saved!";
  }
  else {
    $query = "UPDATE employee SET empno=$empno','lname='$lname',fname='$fname',init= '$init',gender='$gender',bdate='$bdate',dept='$dept',position='$position',pay=$pay,dayswork=$dayswork,otrate=$otrate,othrs=$othrs,allow=$allow,advances=$advances,insurance=$insurance WHERE empno = $empno";
    $msg = "Record updated!";
  }
查看更多
淡お忘
4楼-- · 2019-03-03 19:06

remove '' from your query to be:

$save = "INSERT INTO SONG_AS(ALBUM, CATEGORY, SUB_CATEGORY,
        SONG_NAME, ARTIST, ART_LINK, 
        YEAR, GENRE, SONG_LINK, POST_ON, 
        POST_BY, TOTAL_DOWNLOAD) 
            VALUES('$albm', '$cat', '$scat','$sn', '$art', '$img', '$y', '$g', '$sl', '$time', '', '0')";
查看更多
登录 后发表回答