调用PHP函数时出现致命错误error_message()

时间:2013-12-26 09:15:26

标签: php error-handling

<?php

if (isset($_POST['Submit'])) {
    /* here i am getting variable from form */


    $Post = $_POST["Post"];
    $Fname = $_POST["Fname"];
    $Lname = $_POST["Lname"];
    $Sex = $_POST["Sex"];
    $Marital = $_POST["Mstatus"];
    $Father = $_POST["Father"];
    $Mother = $_POST["Mother"];
    $Husband = $_POST["Hname"];
    $Marital = $_POST["Mstatus"];
    $Spouse = $_POST["Sname"];
    $Son = $_POST["Nson"];
    $Daughter = $_POST["Ndaughter"];
    $Blood = $_POST["Bgroup"];
    $Language = $_POST["Lang"];
    $Dob = $_POST["Dob"];
    $Occu = $_POST["Occu"];
    $Qualification = $_POST["Hqualification"];
    $Nation = $_POST["Nationality"];
    $Conv = $_POST["Conv"];
    $Mobile = $_POST["Mobile"];
    $Email = $_POST["Email"];
    $Income = $_POST["Aincome"];
    $Pass = $_POST["Pass"];
    $Pass_num = $_POST["Passport_num"];
    $Voter = $_POST["Voter"];
    $Voter_num = $_POST["Voter_num"];
    $Address = $_POST["Address"];



    $sql = "INSERT INTO `boward`.`register` (`Post`, `Fname`, `Lname`, `Sex`, `Mstatus`, `Father`, `Mother`, `Hname`, `Sname`, `Nson`, `Ndoughter`, `Bgroup`, `Lang`, `Dob`, `Occu`, `Hqualification`, `Nationality`, `Nationality_other`, `Conv`, `Mobile`, `Email`, `Aincome`, `Pass`, `Passport_num`, `Voter`, `Voter_num`, `Address`, `pic`) VALUES ('$Post', '$Fname', '$Lname', '$Sex', '$Marital', '$Father', '$Mother', '$Husband', '$Marital', '$Spouse', '$Son', '$Daughter', '$Blood', '$Language', '$Dob', '$Occu', '$Qualification', '$Nation', '$Conv', '$Mobile', '$Email', '$Income', '$Pass', '$Pass_num', '$Voter', '$Voter_num', '$Address', '')";

    global $default_dbname;
    $link_id = db_connect($default_dbname);

    /* here i am executing sql statement */

    if (empty($Email)) {
        /* this error_message function giving Fatal error when calling */

        error_message("Enter Desired E-mail Address");
    } else {
        $result = mysql_query($sql);
        echo "<center>Record Inserted</center>";
    }
}
?>

2 个答案:

答案 0 :(得分:0)

此名称error_message()没有任何功能,请使用trigger_error()

答案 1 :(得分:0)

<?php

$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$Email = $_POST["Email"];

// you need $_POST controls

$ArrPost = Array( // They want to control the summer series.
                'Enter First Name'     => $Fname,
                'Enter Last Name'      => $Lname,
                'Enter E-mail Address' => $Email
                );

$i=0;
$count = count($ArrPost);
foreach($ArrPost as $key => $val)
{
    $i++;
    if(empty($val))
    {
        throw new Exception($key);
    }
    elseif($i == $count)
    {
        $result = mysql_query($sql);
        if($result)
            echo "<center>Record Inserted</center>";
    }
}

对不起我的英语。

相关问题