jeudi 28 juillet 2016

Why is echo statement not generating anything in my PHP code?

In my code, I have javacript get the local time on the client side and post it to the server. On the post event, I have the following code in PHP.

<?php 
......
if(isset($_POST["dateStr"]) && strlen(trim($_POST["dateStr"])) > 0)
{
    ....
    if($fh = fopen("files/$fileID",'w'))
    {
        fwrite($fh, '<span style="color:yellow">Successfully created file!</span>');
        echo '<span style="color:yellow">Successfully created file!</span>';
        fclose($fh);
    }
    else
        echo "<span style=\"color:yellow\">Error creating file!</span>";
}
?> 

The file is successfully created, and inside that file (for debugging, to just see what echo statement generates, I dumped the same string in that file) I can the following statement as well.

<span style="color:yellow">Successfully created file!</span>

However, the message "Successfully created file" is not shown on the screen. This means the echo statement is not working. What could be the mistake that I am doing?




Aucun commentaire:

Enregistrer un commentaire