php—当我将惰性数据导入dataabse时,向我显示错误列计数与第1行的值计数不匹配

ou6hu8tu  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(286)
<?php

        ///////////////////////////////////////////////Registration by form//////////////////////////////
        if(isset($_POST['add'])){

        $sr_no=$_POST['sr_no'];
        $roll_no=$_POST['roll_no'];

        $o_tmark=$_POST['o_tmark'];
        $o_vmark=$_POST['o_vmark'];
        $yoga_tmark=$_POST['yoga_tmark'];
        $yoga_vmark=$_POST['yoga_vmark'];

        $s_tmark=$_POST['s_tmark'];
        $s_vmark=$_POST['s_vmark'];
        $i_tmark=$_POST['i_tmark'];
        $i_vmark=$_POST['i_vmark'];
       $o_totalmark=$o_tmark+$o_vmark;
       $yoga_totalmark=$yoga_tmark+$yoga_vmark;
       $s_totalmark=$s_tmark+$s_vmark;
       $i_totalmark=$i_tmark+$i_vmark;

        $date = date('m/d/y');
        $sub1='Obstetrics';
		$sub2='Nat.Yoga Treatment';
		$sub3='Surgery';
		$sub4='Iridology';
if($roll_no !="")
{

$rs=mysqli_query($con,"select * from `bnysfinalyear` where roll_no='$roll_no'");
if (mysqli_num_rows($rs)>0)
{

	  echo "<script type='text/javascript'> alert('User Already Registered'); </script>";
	exit;
} 
else
{
        mysqli_query($con,"INSERT into `bnysfinalyear`(`sr_no`,`roll_no`,`o_tmark`,`o_vmark`,`yoga_tmarks`,`yoga_vmarks`,`s_tamrk`,`s_vamrk`,`ir_tmark`,`ir_vmark`,`o_totalmark`,`yoga_totalmark`,`s_totalmark`,`ir_totalmark`,`date`,`sub1`,`sub2`,`sub3`,`sub4`)
        values('$sr_no','$roll_no','$o_tmark','$o_vmark','$yoga_tmark','$yoga_vmark','$s_tmark','$s_vmark','$i_tmark','$i_vmark','$o_totalmark','$yoga_totalmark','$s_totalmark','$i_totalmark','$date','$sub1','$sub2','$sub3','$sub4')")or die(mysqli_error($con));

        $msg='<div class="alert alert-success">
  <strong>Registration!</strong> Successfuly Submited.
</div>
';

        }

}
		}
        ?>
DATABASE 
`id`, `sr_no`, `roll_no`, `student_name`, `enrol_no`, `o_tmark`, `o_vmark`, `ir_tmark`, `ir_vmark`, `yoga_tmarks`, `yoga_vmarks`, `s_tamrk`, `s_vamrk`, `o_totalmark`, `ir_totalmark`, `yoga_totalmark`, `s_totalmark`, `date`, `sub1`, `sub2`, `sub3`, `sub4`, `status`

当我将数据插入数据库时,显示错误“列计数与行1的值计数不匹配”此。。我正在检查所有数据库字段并计算所有字段,但所有字段都是正确的我正在检查所有字段,但我在任何地方都没有显示任何错误请检查并帮助他解决此问题

lnlaulya

lnlaulya1#

删除此行

if (mysqli_num_rows($rs)>0)

尝试此代码

while($row=mysqli_fetch_assoc($rs)){
      $roll_nos = $row['roll_no'] ;
 if($roll_nos == $roll_no){
  echo "<script type='text/javascript'> alert('User Already Registered'); </script>";
}
else
{
    mysqli_query($con,"INSERT into `bnysfinalyear`(`sr_no`,`roll_no`,`o_tmark`,`o_vmark`,`yoga_tmarks`,`yoga_vmarks`,`s_tamrk`,`s_vamrk`,`ir_tmark`,`ir_vmark`,`o_totalmark`,`yoga_totalmark`,`s_totalmark`,`ir_totalmark`,`date`,`sub1`,`sub2`,`sub3`,`sub4`)
    values('$sr_no','$roll_no','$o_tmark','$o_vmark','$yoga_tmark','$yoga_vmark','$s_tmark','$s_vmark','$i_tmark','$i_vmark','$o_totalmark','$yoga_totalmark','$s_totalmark','$i_totalmark','$date','$sub1','$sub2','$sub3','$sub4')")or die(mysqli_error($con));

    $msg='<div class="alert alert-success">
    <strong>Registration!</strong> Successfuly Submited.
    </div>
    ';

    }
    }

相关问题