PHP错误。如何找到错误的根本原因?

时间:2015-07-14 22:16:45

标签: php

?php session_start(); 
$Body = "";
$errors = 0;

if (!isset($_SESSION['internID'])) {
    $Body .= "<p>You have not logged in or registered. Please return to the <a href='InternLogin.php'>Registration / Log In page</a>.</p>\n";
    ++$errors;
}

if ($errors == 0) {
    if (isset($_GET['opportunityID']))
        $OpportunityID =  $_GET['opportunityID'];
    else {
        $Body .= "<p>You have not selected an opportunity. Please return to the <a href='AvailableOpportunities.php? . SID'>" . 
        "Available Opportunities page</a>.</p>\n";
        ++$errors;
    }
}

/* $DBConnect = FALSE; */
if ($errors == 0){
    $DBConnect = @mysql_connect("localhost", "FAKE", "HELLO");

    if($DBConnect === FALSE) {
        $Body .= "<p>Unable to connect to the database server. Error code " . mysql_errno() .": " . mysql_error() . "</p>\n";
        ++$errors;
 }

 else {
    $DBName = "rac218_internships";
    $result = @mysql_select_db($DBName, $DBConnect);

        if ($result === FALSE) {
        $Body .= "<p>Unable to select the database. Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>\n";
        ++$errors;
        }
    }
}

if ($errors == 0) {
    $TableName = "assigned_opportunities";
    $SQLstring = "DELETE FROM $TableName WHERE opportunityID=$OpportunityID AND internID=$_SESSION['internID'] AND date_approved IS NULL";
    $QueryResult = @mysql_query($SQLstring, $DBConnect);
}
if ($QueryResult === FALSE) {
    $Body .= "<p>Unable to execute the query. Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>\n";
    ++$errors;
}
else {
    $AffectedRows = mysql_affected_rows($DBConnect);

    if ($AffectedRows == 0)
        $Body .= "<p>You had not previously selected opportunity # " . $OpportunityID . ".</p>\n";
    else
        $Body .= "<p>Your request for opportunity # " . $OpportunityID . " has been removed.</p>\n";
}
    mysql_close($DBConnect);

}

 if ($_SESSION['internID'] > 0)
    $Body .= "<p>Return to the <a href='AvailableOpportunities.php? . SID'>Available Opportunities</a> page.</p>\n";
 else
    $Body .= "<p>Please <a href='InternLogin.php'>Register or Log In</a> to use this page.</p>\n";
?>

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Cancel Selection</title>
    <meta charset="utf-8">
</head>
<body>
<h1>College Internship</h1>
<h2>cancel Selection</h2>

<?php echo $Body; ?>
</body>
</html>

它一直说,“解析错误:语法错误,意外T_ENCAPSED_AND_WHITESPACE,期望第42行////CancelSelection.php中的T_STRING或T_VARIABLE或T_NUM_STRING”

我已经完成了五次作业,看不到任何遗漏或错误的内容。有人可以告诉我代码有什么问题或直接指出我如何解决这样的问题?谢谢!

0 个答案:

没有答案