title: Why is my PHP script (MySQL Query) so slow?
body: <p>I ran a script I made a couple of minutes ago and it still hasn't finished running.</p>
  
  <p><strong>Now it has,</strong> I got a 500 Internal Server Error. </p>
  
  <p>EDIT--- The error is occuring on line 126 which is port of the while loop here:</p>
  
  <pre><code>while ($row == mysql_fetch_assoc($query)) {
              mysql_query("DELETE FROM `Likes` WHERE `accountID` = '$id'");
  }
  </code></pre>
  
  <p>Please can you tell me what is causing my script to be so slow?</p>
  
  <pre><code>if ($param == "closeAccount") {
      $username = NULL;
      $password = NULL;
      $emailAdd = NULL;
      $id = NULL;
      if (isset($_GET['username'])) {
          $username = $_GET['username'];
      }
      else {
          exit("No username is set");
      }
      if (isset($_GET['password'])) {
          $password = md5($_GET['password']);
      }
      else {
          exit("No password is set");
      }
      if (isset($_GET['emailAddress'])) {
          $emailAdd = $_GET['emailAddress'];
      }
      else {
          exit("No email address is set");
      }
      $query = mysql_query("SELECT * FROM `Accounts` WHERE `Username` = '$username' AND `Password` = '$password' AND `Email Address` = '$emailAdd'");
      if (mysql_num_rows($query) &lt; 1) {
          exit("Account doesn't exist");
      }
      while ($row = mysql_fetch_assoc($query)) {
          $id = $row["id"];
      }
      $query = NULL;
      $query = mysql_query("SELECT `id` FROM `Comments` WHERE `accountID` = '$id'");
      while ($row = mysql_fetch_assoc($query)) {
          mysql_query("DELETE FROM `Comments` WHERE `accountID` = '$id'") or die(mysql_error());
      }
      $query = NULL;
      $query = mysql_query("SELECT `id` FROM `Likes` WHERE `accountID` = '$id'");
      while ($row == mysql_fetch_assoc($query)) {
          mysql_query("DELETE FROM `Likes` WHERE `accountID` = '$id'");
      }
      $query = NULL;
      $query = mysql_query("SELECT `id` FROM `Posts` WHERE `accountID` = '$id'");
      while ($row == mysql_fetch_assoc($query)) {
          mysql_query("DELETE FROM `Posts` WHERE `accountID` = '$id'");
      }
      $query = NULL;
      $query = mysql_query("DELETE FROM `Accounts` WHERE `Username` = '$username' AND `Password` = '$password' AND `Email Address` = '$emailAdd'");
      exit("Closed");
  }
  </code></pre>