Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 添加一个脚本,说明记录已更新_Php - Fatal编程技术网

Php 添加一个脚本,说明记录已更新

Php 添加一个脚本,说明记录已更新,php,Php,我有更新学生记录的代码 $select_query="select student_id from student_information where student_id = '$student_id'"; $result_set = mysql_query($select_query,$link_id); if($row = mysql_fetch_array($result_set)){ $flag="exists"; header("location:Admin_Hom

我有更新学生记录的代码

$select_query="select student_id from student_information where student_id = '$student_id'";
$result_set = mysql_query($select_query,$link_id);

if($row = mysql_fetch_array($result_set)){
    $flag="exists";
    header("location:Admin_Home.php?flag=$flag&student_id=$student_id");
    die();
}
else{
    /*
        This block is used to insert the learners record in database 
        if the student_id is not yet registered in the database. 
    */
    mysql_query("SET AUTOCOMMIT = 0 ");
    if(mysql_error() != null){
        die(mysql_error());
    }
    $query = "insert into student_information(student_id,student_password,first_name,last_name,registration_date,gender,date_of_birth,";
    $query .= "contact_no,grade,section,LRN,email1,email2,address,description,learner_id)";
    $query .= " values('$student_id','$student_password','$first_name','$last_name',now(),'$gender','$date_of_birth',";
    $query .= "'$contact_no','$grade','$section','$LRN','$email1','$email2','$address','$description','$learner_id')";
    $result = mysql_query($query,$link_id);
    if(mysql_error() != null){
        die(mysql_error());
    }
}
现在,我的问题是放置一个脚本来警告“记录已更新”以及从代码的哪个部分插入。 请告知。

更改此选项:

if(mysql_error() != null){
    die(mysql_error());
}
为此:

if (mysql_error() != null) {
    die(mysql_error());
}
echo "Records updated.";

插入它作为
else
块的最后一行,也就是说,在最后一个
}
之前,
else
实际上不是必需的,因为
die(mysql_error())
退出脚本