Jump to content

mySQL error --> 1 result set(s) not freed.


teddy777

Recommended Posts

I get this when i fill out a form and submit it to my database.

 

Warning: Unknown: 1 result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query() in Unknown on line 0.

 

I've got my php code, this is my first one so its fairly crap.

myusername=$_POST['myusername'];
$password1=$_POST['password1'];
$password2=$_POST['password2'];
$myemailaddress=$_POST['email'];

$sql="SELECT * FROM $tbl_name WHERE username='$myusername'";
$result=mysql_query($sql);

if($_POST['submit']){
  //username checking
  if($myusername && strlen($myusername) >= 3){
    $query = mysql_query("SELECT `id` FROM `tutreg` WHERE `username`='". $myusername."' LIMIT 1");
    if(mysql_num_rows($query)){
      $error['userexists'] = 'Username exists';
    }
  } else {
    $error['usernameinput'] = 'Please enter a username of 3+ characters';
  }
  //email checking
  if($myemailaddress){
     if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $myemailaddress)){
      $error['emailerror'] = 'Email Incorrect';
    }
  } else {
  $error['emailinput'] = 'Please supply an email address'; 
  }
  
  //Password checking
  if($password1 && $password2){
    if($password1 != $password2){
      $error['passmismatch'] = 'Passwords don\'t match';
    }
  } else {
  $error['passwordinput'] = 'Please enter your password in both fields';
  }
}
  if(!$error && $_POST['submit']){

  $sql = mysql_query("INSERT INTO `tutreg` (username, password, email) VALUES ('".$myusername."', '".md5($password1)."', '".$myemailaddress."')");
  if($query){
  echo $myusername .' is now registered';
}
}
// Free memory
mysql_free_result($result);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.