<?php
$id=$_REQUEST['id'];
$sub=array();
$sub=$_REQUEST['sub'];
$total=0;
for($i=0;$i<count($sub); $i++)
{
$total=$total+$sub[$i];
}
$link=mysql_connect("localhost","root","") or die("Cannot Connect to the database!");
mysql_select_db("nps_exam",$link) or die ("Cannot select the database!");
$query= "UPDATE four SET 'sub[1]'='".$sub[0]."' , 'sub[2]'='".$sub[1]."' , 'sub[3]'='".$sub[2]."' , 'sub[4]'='".$sub[3]."' , 'sub[5]'='".$sub[4]."' , 'sub[6]'='".$sub[5]."' , 'sub[7]'='".$sub[6]."' , 'sub[8]'='".$sub[7]."' , 'sub[9]'='".$sub[8]."' , 'Music'='".$sub[9]."' , 'Arts'='".$sub[10]."' , 'total'='".$total."' WHERE Registration_no=='".$id."'";
if(!mysql_query($query,$link))
{die ("An unexpected error occured while saving the record, Please try again!");}
else
{
echo "Record updated successfully!";}
?>
我是 php 的新手。同时从上面的 php 代码更新记录。我总是收到错误消息说保存记录时发生意外错误,我也无法更新我的数据..请任何人帮助..