-1

你好朋友我没有太多的PHP技能。请帮我处理这段代码。它显示语法错误意外文件结尾。我已经测试过但失败了。当我从文件中删除此代码时,页面显示正确,但当我再次粘贴此代码时,它显示相同的错误。

该文件仅包含此代码,因此可能存在括号、句号或其他问题,请更正它并在您的答案中给出固定代码。爱你们,你们真的在帮助有需要的人。

<?php
include("include/header.php");
if (!isset($_SESSION["userlogin"])) {
    header("location: login.php");
    exit();
}
$edit = dbFetchArray(dbQuery("select * from `user_registration` where `email`='" . $_SESSION["userlogin"] . "'"), MYSQL_BOTH);
$Id = base64_decode($_REQUEST['Id']);
$up = mysql_fetch_array(mysql_query("select * from `jobs` where `id`='" . $Id . "'"));
$status = stripslashes($up["highlighted"]);
$name = stripslashes($up["title"]);
$explode = explode(" ", $name);
$tit = isset($explode[0]) ? $explode[0] : '';
$col = isset($explode[1]) ? $explode[1] : '';
$cat = isset($explode[2]) ? $explode[2] : '';

$user = mysql_fetch_array(mysql_query("select * from `user_registration` where `email`='" . $_SESSION["userlogin"] . "'"));
$fullname = stripslashes($user['fullname']);
$customer_id = $user['id'];
$current_balence = $user['current_balance'];

if (isset($_POST["Button"])) {
    if (isset($_REQUEST["Available_positions"])) {
        $Available_positions = $_POST["Available_positions"];
        if (strpos($Available_positions, '.') === false) {
            $pos = $Available_positions;
            $pos1 = 0;
        } else {
            $pieces = explode(".", $Available_positions);
            $pos = $pieces[0];
            $pos1 = $pieces[1];
        }

        $Payment_per_task = $_POST["Payment_per_task"];

        $hid = $_REQUEST['hid'];
        if ($pos1 > 0) {
            ?>
            <script>
                alert('Job Posting Suspended');
                window.location.href="edit_job.php?Id=<?= base64_decode($hid) ?>";
            </script>
            <?
        } else {
            dbQuery("update `jobs` set `wd2`='" . $Available_positions . "',`price`='" . $Payment_per_task . "' where `id`='" . $hid . "' and `email`='" . $_SESSION["userlogin"] . "'");
            ?>
            <script>
                window.location.href="employer.php";
            </script>
            <?
        }
    }
    $_SESSION['hid'] = $hid;
    if ($hid > 0) {
        $_SESSION["success"] = '';
    } else {
        $_SESSION["error"] = '';
    }
} else if (isset($_POST["Cancel"])) {
    $hid = $_REQUEST['hid'];
    dbQuery("update `jobs` set `status`='3' where `id`='" . $hid . "' and `email`='" . $_SESSION["userlogin"] . "'");
    $resJ = dbFetchArray(dbQuery("select * from `jobs` where `id`='" . $hid . "' and `email`='" . $_SESSION["userlogin"] . "'"), MYSQL_BOTH);

    if ($resJ["wd1"] != $resJ["wd2"]) {
        $CJ = $resJ["wd2"] - $resJ["wd1"];
        $CJFees = $CJ * $resJ["price"];
        dbQuery("insert into `myaccount`(`email`,`amount`,`type`,`createdate`,`jobid`) values('" . $_SESSION['userlogin'] . "','$CJFees','10',NOW(),'" . $resJ["id"] . "')");
        $rescurbal = dbFetchArray(dbQuery("select * from `user_registration` where `email`='" . $_SESSION['userlogin'] . "'"), MYSQL_BOTH);
        dbQuery("update `user_registration` set `current_balance`='" . ($rescurbal["current_balance"] + $CJFees) . "' where `email`='" . $_SESSION['userlogin'] . "'");
    }
    ?>
    <script>
        window.location.href="employer.php";
    </script>
    <?
}
?>
4

3 回答 3

1

将大块代码一一剪切,刷新页面。如果需要,您可以使用die函数停止进一步的脚本执行,以检查脚本是否执行到某个点而不会产生错误。

当错误消失时,这意味着它在您刚刚剪切的块中。然后逐行重复程序,这样你就可以定位错误了。它应该是括号、引号、分号或类似内容的语法错误。

于 2013-04-14T10:56:12.013 回答
0

另外,请确保您的文件编码是 UTF-8,没有 BOM。

include ("include/header.php");
if(!isset($_SESSION["userlogin"]))
{
    header("location: login.php");
    exit();
}
$edit = dbFetchArray(dbQuery("select * from `user_registration` where `email`='".$_SESSION["userlogin"]."'"),MYSQL_BOTH);
$Id = base64_decode($_REQUEST['Id']);
$up = mysql_fetch_array(mysql_query("select * from `jobs` where `id`='".$Id."'"));
$status = stripslashes($up["highlighted"]);
$name = stripslashes($up["title"]);
$explode = explode(" ",$name);
$tit = isset($explode[0]) ? $explode[0] : '';
$col = isset($explode[1]) ? $explode[1] : '';
$cat = isset($explode[2]) ? $explode[2] : '';

$user = mysql_fetch_array(mysql_query("select * from `user_registration` where `email`='".$_SESSION["userlogin"]."'"));
$fullname = stripslashes($user['fullname']);
$customer_id = $user['id'];
$current_balence = $user['current_balance'];

if(isset($_POST["Button"]))
{
    if(isset($_REQUEST["Available_positions"]))
    {
        $Available_positions = $_POST["Available_positions"];
        if(strpos($Available_positions,'.') === false)
        {
            $pos = $Available_positions;
            $pos1 = 0;
        }
        else
        {
            $pieces = explode(".",$Available_positions);
            $pos = $pieces[0];
            $pos1 = $pieces[1];
        }

        $Payment_per_task = $_POST["Payment_per_task"];

        $hid = $_REQUEST['hid'];
        if($pos1 > 0)
        {

?>
<script>
alert('Job Posting Suspended');
window.location.href="edit_job.php?Id=<?= base64_decode($hid)?>";
</script>
<?

        }
        else
        {
            dbQuery("update `jobs` set `wd2`='".$Available_positions."',`price`='".$Payment_per_task."' where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'");

?>
 <script>
window.location.href="employer.php";
</script>
<?

        }
    }
    $_SESSION['hid'] = $hid;
    if($hid > 0)
    {
        $_SESSION["success"] = '';
    }
    else
    {
        $_SESSION["error"] = '';
    }
}
else
{
    if(isset($_POST["Cancel"]))
    {
        $hid = $_REQUEST['hid'];
        dbQuery("update `jobs` set `status`='3' where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'");
        $resJ = dbFetchArray(dbQuery("select * from `jobs` where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'"),MYSQL_BOTH);

        if($resJ["wd1"] != $resJ["wd2"])
        {
            $CJ = $resJ["wd2"] - $resJ["wd1"];
            $CJFees = $CJ * $resJ["price"];
            dbQuery("insert into `myaccount`(`email`,`amount`,`type`,`createdate`,`jobid`) values('".$_SESSION['userlogin']."','$CJFees','10',NOW(),'".$resJ["id"]."')");
            $rescurbal = dbFetchArray(dbQuery("select * from `user_registration` where `email`='".$_SESSION['userlogin']."'"),MYSQL_BOTH);
            dbQuery("update `user_registration` set `current_balance`='".($rescurbal["current_balance"] + $CJFees)."' where `email`='".$_SESSION['userlogin']."'");
        }

?>
<script>
window.location.href="employer.php";
</script>
<?
    }
}
于 2013-04-14T10:56:51.623 回答
-2

如果您没有激活短标签,则必须使用<?php, 因为<?. 否则 PHP 会忽略<? ... ?>. 因此会缺少括号,因此会出现语法错误,就像您得到的那样。

于 2013-04-14T10:54:06.670 回答