2013-11-23 90 views
0

問題在哪裏?然後我打開我的/ localhost顯示消息「解析錯誤:語法錯誤,意外的T_STRING在...」中的.PHP 也許代碼不正確?解析錯誤:語法錯誤,意外T_STRING

<?php 
     if($_POST) { 
      $name = $_POST['news_name']; 
      $content = $_POST['news_text']; 
      $handle = fopen ("z_padomi_ka_atmest_smekesanu.php","a"); 
      fwrite($handle,"<b>".$name."</b>:<br/>".$content."<br/> 
      fclose($handle); 
      } 
     ?> 

<script type="text/javascript"> 


    document.getElementById('com-form').action = "z_padomi_ka_atmest_smekesanu.php"; 


    </script> 
    <form action = "" method="post"> 
    <p class="left"><label for="news_name"><b>Vārds:</b></label><br/><input type="text" name="news_name" id="news_name" value="" size="15" class="input big8"></p> 
    <p class="even"><label for="news_text"><b>Pievienot atbildi:</b></label><br/><textarea name="news_text" id="news_text" cols="75" rows="3" wrap="virtual"></textarea></p> 
    </p><p class="buttons right"><input id="add" type="submit" value="Pievienot" class="submit"><br> 
    <li><a style="text-decoration: underline; padding-right:10px; padding-top:5px" href="pamaciba.html" target="_blank">Komentāru noteikumi</a></p> 
    </form> 
     <?php include "z_padomi_ka_atmest_smekesanu.php"; 
    </script> 
+0

看看fwrite調用的結尾,您忘記了結束函數調用,並且字符串缺少結束引號。 – jbub

回答

2

你忘了關閉一個字符串。

更改此

fwrite($handle,"<b>".$name."</b>:<br/>".$content."<br/> 
fclose($handle); 

對此

fwrite($handle,"<b>".$name."</b>:<br/>".$content."<br/>"); 
fclose($handle); 

編輯

你忘了一個PHP結束標記過:

<?php include "z_padomi_ka_atmest_smekesanu.php"; 
    </script> 

<?php include "z_padomi_ka_atmest_smekesanu.php"; ?> 
    </script> 
+0

,可能忘記關閉底部的<?php標記 –

+0

是的,我沒有看到。我將它添加到我的答案中。 – OlivierH

相關問題