Error in PHP code?
<p>I have been studying PHP from Head First PHP and MySQL. So in Chapter 5 the example is for a game score keeper so instead of just copying code from the examples I tried to implement it myself for a COD4 score tracker but I get an error.</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
        &lt;title&gt;Add your score&lt;/title&gt;
        &lt;h2&gt;Thing you got what it takes? &lt;/h2&gt;
        &lt;h2&gt;Add your score then....&lt;/h2&gt;
    &lt;/head&gt;
    &lt;body background="cod4/bgimage.jpg"&gt;
        &lt;?php
  if (isset($_POST['submit'])) {
    // Grab the score data from the POST
    $name = $_POST['name'];
    $score = $_POST['score'];
    $deaths = $_POST['deaths'];
    $screenshot = $_FILES['screenshot']['name'];
    $screenshot_size = $_FILES['screenshot']['size'];
    $screenshot_errors= $_FILES['screenshot']['error'];

    if(!empty($name) &amp;&amp; !empty($score) &amp;&amp; !empty($deaths) &amp;&amp; !empty($screenshot) &amp;&amp; ($screenshot_size &gt; 0) &amp;&amp; ($screenshot_errors == 0)) {

       //Move uploaded Image
       $imgloc = '/cod4/images/'.$screenshot;

        if(move_uploaded_file($_FILES['screenshot']['tmp_name'], $imgloc))
        {
        echo '&lt;p&gt;Tes&lt;/p&gt;';
      // Connect to the database
      $dbc = mysqli_connect('localhost', 'root', '', 'cod4')
       or die('Error connecting database.');

      // Write the data to the database
      $query = "INSERT INTO scores VALUES(0, NOW(), '$name', '$score', '$deaths', '$screenshot')";
      mysqli_query($dbc, $query)
       or die('Error querying database.');

      // Confirm success with the user
      echo '&lt;p&gt;Thanks for adding your new high score!&lt;/p&gt;';
      echo '&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt; ' . $name . '&lt;br /&gt;';
      echo '&lt;strong&gt;Score:&lt;/strong&gt; ' . $score . '&lt;br /&gt;';
      echo '&lt;strong&gt;Deaths:&lt;/strong&gt; ' . $deaths . '&lt;/p&gt;';
      echo '&lt;img src="'.$imgloc.'" alt="Score image"';
      echo '&lt;p&gt;&lt;a href="index.php"&gt;&amp;lt;&amp;lt; Back to high scores&lt;/a&gt;&lt;/p&gt;';

      // Clear the score data to clear the form
      $name = "";
      $score = "";
      $deaths = "";
      $screenshot = "";

      mysqli_close($dbc);
  }
  else
  {
      echo '&lt;p clas="error"&gt;Error compying &lt;/p&gt;';
      }
    }
    else {
      echo '&lt;p class="error"&gt;Please enter all of the information to add your high score.&lt;/p&gt;';
    }
  }
?&gt;

  &lt;hr /&gt;
  &lt;form enctype="multipart/form-data" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
  &lt;input type="hidden" name="MAX_FILE_SIZE"  value="32768000" /&gt;

    &lt;label for="name"&gt;Nickname:&lt;/label&gt;
    &lt;input type="text" id="name" name="name" value="&lt;?php if (!empty($name)) echo $name; ?&gt;" /&gt;&lt;br /&gt;


    &lt;label for="score"&gt;Score:&lt;/label&gt;
    &lt;input type="text" id="score" name="score" value="&lt;?php if (!empty($score)) echo $score; ?&gt;" /&gt;&lt;br /&gt;

    &lt;label for="deaths"&gt;Deaths:&lt;/label&gt;
    &lt;input type="text" id="deaths" name="deaths" value="&lt;?php if (!empty($score)) echo $score; ?&gt;" /&gt;&lt;br /&gt;

    &lt;label for="deaths"&gt;Screenshot:&lt;/label&gt;
    &lt;input type="file" id="screenshot" name="screenshot" /&gt;

    &lt;hr /&gt;
    &lt;input type="submit" value="Add" name="submit" /&gt;
  &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The problem is I get a message from the else saying that there is an error in copying pls help. I've tried to shorten the code as much as possible.</p>

<p>EDIT: Here is the entire code. I dont get any syntax errors. But I cant seem to move the uploaded file. And I am running XAMPP on Ubuntu 11.10. I tried using <code>sudo chmod -R 777 cod4</code>. But still I cant move the files. Made a few changes now I get an error </p>

<pre><code>Warning: move_uploaded_file(/cod4/images/94074323-4.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /opt/lampp/htdocs/cod4/addscore.php on line 25

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpRuh1OQ' to '/cod4/images/94074323-4.jpg' in /opt/lampp/htdocs/cod4/addscore.php on line 25
</code></pre>
