<div dir="ltr"><div dir="ltr">I saved this script and visited the page in my browser. PHP reports a helpful error message:<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">Parse error</b><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">: syntax error, unexpected '<' in </span><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">/var/www/sandbox/upload.php</b><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> on line </span><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">24<br></b></blockquote><div dir="ltr"><br></div>After correcting line 24, I visited it again and PHP reported:<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">Parse error</b><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">: syntax error, unexpected '}', expecting ',' or ';' in </span><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">/var/www/sandbox/upload.php</b><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> on line </span><b style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">38</b></div></blockquote><div><p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal"><br></p><p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal">After correcting line 38, there were no further syntax errors. I haven’t checked whether the script does what is intended, but the syntax is at least correct.</p><p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small"><br></span></p><p class="MsoNormal" style="margin:0cm 0cm 0.0001pt;line-height:normal"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small">If you aren't seeing these PHP error messages, you need to turn them on. It looks like you're using Apache. Based on a quick Google, you should add the following into your php.ini file:</span><br></p></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="monospace">error_reporting = E_ALL</font></div></div><div><div><font face="monospace">display_errors = On</font></div></div><font face="monospace">display_startup_errors = On<br></font><br></blockquote>It looks like there's already a php.ini file in the same directory as your scripts; add the above directives to it.<div><br></div><div>Note that I had to save your script as upload.php not upload.html to get it to run.</div><div><br></div><div>It might take a couple of goes to get PHP and Apache sorted such that they output all errors (including parse errors), but it will be worth it as it makes debugging much easier than simply eyeballing the code for errors.</div><div><br></div><div>Best of luck,</div><div>Matthew<br><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 14 May 2020 at 09:55, Andrew Ramage <<a href="mailto:andrew.ramage.1963@gmail.com" target="_blank">andrew.ramage.1963@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div>
    <p>I still do not see a syntax error in this file:</p>
    <p><u>upload.html</u></p>
    <p><!doctype html><br>
      <br>
      <html><br>
      <br>
      <br>
      <?php<br>
         error_reporting(E_ALL);<br>
      <br>
      <br>
      $target_dir = "Music/";<br>
      $target_file = $target_dir .
      basename($_FILES["fileToUpload"]["name"]);<br>
      $uploadOk = 1;<br>
      $audioFileType =
      strtolower(pathinfo($target_file,PATHINFO_EXTENSION));<br>
      <br>
      // Check if file already exists<br>
      echo "First if";<br>
      if (file_exists($target_file)) {<br>
          echo "Sorry, file already exists.";<br>
          $uploadOk = 0;<br>
      } <br>
      echo "Second if";<br>
      // Allow certain file formats<br>
      if (($audioFileType != "mp3") && ($audioFileType !=
      "ogg"))  {<br>
          echo $audioFileType . <br> . "Sorry, only MP3 and OGG
      files are allowed.";<br>
          $uploadOk = 0;<br>
      } <br>
      // Check if $uploadOk is set to 0 by an error<br>
      echo "Third if";<br>
      if ($uploadOk == 0) {<br>
          echo "Sorry, your file was not uploaded.";} <br>
      // if everything is ok, try to upload file<br>
       else {<br>
          "Fourth if";<br>
          if (move_uploaded_file($_FILES ["fileToUpload"]["tmp_name"],
      $target_file)) {<br>
              echo "The file ". basename(
      $_FILES["filndow.alerteToUpload"]["name"]). " has been uploaded.";
      } <br>
          else {<br>
              echo "Sorry, there was an error uploading your file." <br>
               }<br>
          }<br>
      ?><br>
      <br>
      </html><br>
      <br>
    </p>
  </div>

-- <br>
EdLUG mailing list<br>
<a href="mailto:EdLUG@lists.edlug.org.uk" target="_blank">EdLUG@lists.edlug.org.uk</a><br>
<a href="https://lists.edlug.org.uk/mailman/listinfo/edlug" rel="noreferrer" target="_blank">https://lists.edlug.org.uk/mailman/listinfo/edlug</a></blockquote></div></div></div>