我认为错误应该是插入字段中的数字与值中的数字不匹配,但我真的看不出我的代码中有什么问题。错误是“这里是错误:列数与第1行的值计数不匹配”,这表明我的插入中出现了错误:
<?
$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);
?>
答案 0 :(得分:3)
看起来你错过了行尾的逗号
'".$row2[projectbenefits]."'