it is not displaying the messages correctly
<p>I have a javscript function below which displays a message depending on on the result:</p>

<pre><code>   function stopImageUpload(success){
          var result = '';
          if (success == 1){
             result = '&lt;span class="msg"&gt;The file was uploaded successfully!&lt;\/span&gt;&lt;br/&gt;&lt;br/&gt;';
          }
          else {
             result = '&lt;span class="emsg"&gt;There was an error during file upload!&lt;\/span&gt;&lt;br/&gt;&lt;br/&gt;';
          }  
          return true;   
    }
</code></pre>

<p>The code below always displays the message "The file was uploaded successfully!"</p>

<pre><code>   &lt;?php

       $destination_path = str_replace("//", "/", $_SERVER['DOCUMENT_ROOT']."/")."ImageFiles";

       $result = 0;

       $target_path = $destination_path . basename( $_FILES['fileImage']['name']);

       if(move_uploaded_file($_FILES['fileImage']['tmp_name'], $target_path)) {
          $result = 1;
       }

       sleep(1);

    ?&gt;

   &lt;script type='text/javascript' language='javascript'&gt;
      window.top.window.stopImageUpload(1);
   &lt;/script&gt;
</code></pre>

<p>But if I change the last line to this below then it always displays the message "There was an error during file upload!". Why is this and how  can it be fixed so it displays the right message depending on the result?</p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  window.top.window.stopImageUpload(&lt;?php echo $result; ?&gt;);
&lt;/script&gt;
</code></pre>
