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
https://forums.phpfreaks.com/topic/150965-mysql-error-1-result-sets-not-freed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.