Reputation: 39
I think the error should be number in insert fields doesn't match the number in value, but I really cannot see what's wrong in my code. The error is "Here is the error: Column count doesn't match value count at row 1" which shows that it is something wrong in my insert:
<?
$con2=mysqli_connect("localhost","root","","test");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result2= mysqli_query($con2,"SELECT projects.*, org.orgname FROM projects left outer join org on projects.orgid = org.orgid where projects.projectid = '".$projectid."'");
$row2 = mysqli_fetch_array($result2);
$con3 = mysql_connect("localhost","root","");
if (!$con3)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con3);
echo $row2[target];
$sql3 = "INSERT INTO projectlog
(projectid,projectname,generaluserid,adminuserid,swdfphase,target,objective,type,projectsize,commonth,comyear,duration,detail,projectstatus,projectsatisfaction,overallcomments,projectbenefits,orgid,createtime,lastupdatetime,logcreatetime,userid)
VALUES
('".$projectid."',
'".$row2[projectname]."',
'".$row2[generaluserid]."',
'".$row2[adminuserid]."',
'".$row2[swdfphase]."',
'".$row2[target]."',
'".$row2[objective]."',
'".$row2[type]."',
'".$row2[projectsize]."',
'".$row2[commonth]."',
'".$row2[comyear]."',
'".$row2[duration]."',
'".$row2[detail]."',
'".$row2[projectstatus]."',
'".$row2[projectsatisfaction]."',
'".$row2[overallcomments]."',
'".$row2[projectbenefits]."'
'".$row2[orgid]."',
'".$row2[createtime]."',
'".$row2[lastupdatetime]."',
now(),
'".$_SESSION[myid]."')";
if (!mysql_query($sql3,$con3))
{
die('Here is the error: ' . mysql_error());
}
mysql_close($con3);
?>
Upvotes: 0
Views: 63
Reputation: 3854
It looks like you are missing a comma at the end of the line
'".$row2[projectbenefits]."'
Upvotes: 3