title: Error in writing to database
body: <p>I'm writing some data to a database using php. 99% of the time, the data is correctly written to the database. But sometimes, blank data is being inserted into the database. I dont think its a issue with my code, since I can write the data to the database most of the time.</p>
  
  <p>If the server on which the database resides have a slow internet connection, or if the user have a slow internet connection in their pc, can this happen?</p>
  
  <p>Actually there is a slight mistake..Seems like the data that gets blank, comes from a session variable. How can be the session variable get blanked at some time ?</p>
  
  <p>This is the code by which the data get stored into the session variable:</p>
  
  <pre><code>if(!preg_match('/^[a-zA-Z0-9._\-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/', $email))
  $count = 2;
  if(!preg_match('/^[A-Za-z0-9]{6}+$/',$key))
  $count = 2;
  if(!$count)
  {
  $result = mysql_query("SELECT * FROM test WHERE verify = '$key' AND email = '$email'");
  $count = mysql_num_rows($result);
  if($count == 1)
   {
    $row = mysql_fetch_row($result);
    $_SESSION['id'] = $row[0];
    $_SESSION['name'] = $row[1];
    $_SESSION['email'] = $email;
    $_SESSION['pass'] = $row[3];
    $_SESSION['key'] = $key;
    mysql_close();
   }
  }
  </code></pre>
  
  <p>When it happens, all the 5 variables id, name, email, pass and key, becomes blank. Email, and Key is not taken from the Database. The key field contains only alphanumeric content. So is there a way the data taken from the database as well at the GET variables to go blank? ( but even then $count should 1). Because, only if $count is 1, can the data be written to the new table ( where it get blanked )</p>
  
  <p>There are 2 forms. When the user completes the first form, that data is stored in a table test, and a verification mail is sent to them. From the verification link, i find out their key and email, and check the table test, to see whether they are valid. If they are valid ( that means $count is 1 ), then a new form is displayed to the user, where they are asked to enter few more details. Then all the data ( this new data, and also the data that was written to the table test ), shall be written to a new table.</p>
  
  <p>This is where things go wrong. The new data is written perfectly to the new table. But the old data, that was stored in the table test, and copied to the session variable, becomes blank sometimes. I have posted its code above, showing how the session variables are set.</p>
  
  <p>It shall be helpful if someone could point out my mistake, if its something wrong in my code.</p>