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 }

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

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP