dongzhuan1185 2016-02-04 23:01
浏览 26
已采纳

php实时文档错误[重复]

This question already has an answer here:

I have the following code I have thrown together for a sort of live document per say in php, and html. It worked yesterday, but for some strange reason today It decided not to work. It was meant to save a file to server(.txt) and also display that file. here is my code:

<html>
<body>
    <form name="savefile" method="post" action="">
 <input type="hidden" name="filename" value="code"><br/>
        <textarea rows="16" cols="100" name="textdata">
            <?php 
    $text = file_get_contents('user.txt');
    echo $text;
?>
        </textarea><br/>
        <input type="submit" name="submitsave" value="Save">
</form>
    File Contents:<br/>
    <?php
    if (isset($_POST)){
        if ($_POST['submitsave'] == "Save"  && !empty($_POST['filename'])) {
            if(!file_exists($_POST['filename'] . ".txt")){
                $file = tmpfile();
            }
            $file = fopen($_POST['filename'] . ".txt","a+");
            while(!feof($file)){
                $old = $old . fgets($file). "<br />";
            }
            $text = $_POST["textdata"];
            file_put_contents($_POST['filename'] . ".txt", $old . $text);
            fclose($file);
        }
    ?>
</body>
</html>

this is a php file btw the php in the textarea works, but the php that saves the text to the serverside is broken. this is my error: Parse error: syntax error, unexpected end of file in /homepages/31/d585123241/htdocs/test/red.php on line 27

</div>
  • 写回答

1条回答 默认 最新

  • douxuanyi2813 2016-02-05 12:30
    关注

    Your last if is not closed. Add another }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?