-4

是说,

解析错误:语法错误,第 96 行 /mnt/sdcard/www/parts/background/editProfilePic_Process.php 中的文件意外结束

找不到错误。

这是代码:

    <?php

session_start();
$site="http://".$_SERVER["HTTP_HOST"]."/";
$root=$_SERVER["DOCUMENT_ROOT"];
if(substr($root,-1)!="/")
{
$root=$root."/";
}


 if(!isset($_SESSION["u"]))
{
header("location:".$site."user");
exit;
} 
 else{
$u=$_SESSION["u"];
}
 if(!isset($_POST["access"]))
{
echo "You cannot access this page";
exit;

} 
?>



<!DOCTYPE html>
<html>
<head>

<?php 
include($root."parts/resources.php");

?>
</head>
<body>

<?php
// header also contents the <noscript> alert 
include($root."parts/header.php");

?>
<div class="wholepage">

<div class="page scatterList">


 <?php 
if(isset($_FILES["profilePic"]))
{
$name=$_FILES["profilePic"]["name"];

if($_FILES["profilePic"]["error"] !== UPLOAD_ERR_OK) {
die("Upload failed with error code ".$_FILES["profilePic"]["error"]); 
} 

if(!getimagesize($_FILES["profilePic"]["tmp_name"]))
{
 exit;
}

$path=$site."img/1/".$u.".jpg";

move_uploaded_file($path, $_FILES["profilePic"]["tmp_name"]);
}
?>

</div> <!-- end of .page -->


</div> <!-- wholepage -->
<!-- FOOTER -->
<?php 
include($root."parts/footer.php");
?>

</body>
</html>

我应该怎么做才能摆脱它?

4

5 回答 5

1

您忘记在isset if 循环上关闭大括号。试试这个代码。

<?php

    session_start();
    $site="http://".$_SERVER["HTTP_HOST"]."/";
    $root=$_SERVER["DOCUMENT_ROOT"];
    if(substr($root,-1)!="/")
    {
        $root=$root."/";
    }


    if(!isset($_SESSION["u"]))
    {
        header("location:".$site."user");
        exit;
    }
    else{
        $u=$_SESSION["u"];
    }
    if(!isset($_POST["access"]))
    {
        echo "You cannot access this page";
        exit;

    }
    ?>



<!DOCTYPE html>
<html>
<head>


    <?php
    include($root."parts/resources.php");

    ?>



</head>
<body>


<?php
    // header also contents the <noscript> alert
    include($root."parts/header.php");

    ?>
<div class="wholepage">

<div class="page scatterList">


<?php



    if(isset($_FILES["profilePic"]))
            {
                $name=$_FILES["profilePic"]["name"];

                if($_FILES["profilePic"]["error"] !== UPLOAD_ERR_OK) {
                    die("Upload failed with error code ".$_FILES["profilePic"]["error"]);
                }

                if(!getimagesize($_FILES["profilePic"]["tmp_name"]))
                {
                    exit;
                }

                $path=$site."img/1/".$u.".jpg";

                move_uploaded_file($path, $_FILES["profilePic"]["tmp_name"]);
            }

                ?>







            </div> <!-- end of .page -->


            </div> <!-- wholepage -->
            <!-- FOOTER -->
                <?php
                include($root."parts/footer.php");
                ?>


            </body>
            </html>
于 2013-08-14T13:09:57.243 回答
1

第 48 行:如果开始

if (isset ($_FILES["profilePic"])) {

}结束标签不存在。

}标签放在move_uploaded_file第 57 行之后或您想要的位置。

像这样:

if (isset ($_FILES["profilePic"])) {
   $name = $_FILES["profilePic"]["name"];
   if ($_FILES["profilePic"]["error"] !== UPLOAD_ERR_OK) {
      die("Upload failed with error code " . $_FILES["profilePic"]["error"]);
   }

   if (!getimagesize($_FILES["profilePic"]["tmp_name"])) { exit;}

   $path = $site . "img/1/" . $u . ".jpg";
   move_uploaded_file($path, $_FILES["profilePic"]["tmp_name"]);
}
于 2013-08-14T13:09:59.300 回答
1

你还没有关闭这个块

 if(isset($_FILES["profilePic"]))
 {
于 2013-08-14T13:10:09.873 回答
0

你没有完成其中一个 if 语句。

改变:

if(isset($_FILES["profilePic"]))
{
$name=$_FILES["profilePic"]["name"];

到:

if(isset($_FILES["profilePic"]))
{
$name=$_FILES["profilePic"]["name"];
}
于 2013-08-14T13:11:14.920 回答
0
        <?php 
        if(isset($_FILES["profilePic"]))
        {
        $name=$_FILES["profilePic"]["name"];

        if($_FILES["profilePic"]["error"] !== UPLOAD_ERR_OK) {
        die("Upload failed with error code ".$_FILES["profilePic"]["error"]); 
        } 

        if(!getimagesize($_FILES["profilePic"]["tmp_name"]))
        {
         exit;
        }

        $path=$site."img/1/".$u.".jpg";

        move_uploaded_file($path, $_FILES["profilePic"]["tmp_name"]);
        }// this one

        ?> 

你从来没有关闭过第一个 if 语句..

于 2013-08-14T13:11:24.910 回答