语法错误,意外的文件结束

时间:2015-07-06 00:01:54

标签: php

我在下面的代码中没有看到问题。似乎工作正常,然后突然它给我一个意外的文件错误结束。有什么帮助吗?

<?php

require_once 'dblogin.php';
$db_server = mysql_connection($db_hostname, $db_username, $db_password);

if (!db_server) die("Unable to connect MYSQL:" . mysql_error());

mysql_select_db($db_database, $db_server)
or die ("Unable to select database: " . mysql_error());

if (isset($_POST['delete']) && isset($_POST['Degree Plan']))  {

    $degreeplan = get_post('Degree Plan');
    $query = "DELETE FROM DegreePlan WHERE DegName='$degreeplan'";

    if (!mysql_query($query, $db_server))
        echo "DELETE failed: $query<br />" . mysql_error() . "<br /> <br />";
}

    if (isset($_POST['Degree Plan']) && isset($_POST['Dept ID'])) {

        $degreeplan = get_post('Degree Plan');
        $deptID = get_post('Dept ID');
        $query = "INSERT INTO DegreePlan(DegName, DeptId) VALUES ('$degreeplan', '$deptID')";
        if (!mysql_query($query, $db_server))
            echo "DELETE failed: $query<br />" . mysql_error() . "<br /> <br />";
    }


echo <<<_END

<form action="track.php" method="post"> <pre>
Degree Plan <input type = "text" name = "Degree Plan" />
Dept ID     <input type = "text" name = "Dept ID" />
            <inout type = "submit" value = "ADD RECORD" />

</pre> </form>
_END;

$query = "SELECT * FROM DegreePlan";
$result = mysql_query($query);

if (!$result) die ("Database access failed: " . mysql_error());

$rows = mysql_num_rows($result);

for ($j=0; $j<$rows; ++$j) {

    $row = mysql_fetch_row($result);
    echo <<<_END

<pre>
Degree Plan $row[0]
Dept ID     $row[1]
</pre>

<form action = "track.php" method ="post">
    <input type = "hidden" name = "delete" value = "yes" />
    <input type = "hidden" name = "Degree Plan" value = "$row[1]" />
    <input type = "submit" value = "DELETE RECORD" />
</form>

_END;

}

mysql_close($db_server);

function get_post($var)  {

    return mysql_real_escape_string($_POST[$var]);

}

?>

代码是使用php页面更新或删除sql表上的条目。关于它是什么的任何想法我做错了?我甚至用括号和分号检查。我已经检查了所有可能的重复问题,但找不到解决方案。

我正在使用Mac上的XAMPP。运行5.6.8版本的php。 Short_open_tag已启用。我在phpinfo()中检查了它。

0 个答案:

没有答案