Jump to content

blank entries in the database


fife

Recommended Posts

I have an issue with some code I have.  All the code works correctly apart from when submit is clicked not only does it update a the current club but it creates a blank entry in the database!  I cant see whats wrong.  Here is the code.........

 


//gets
$validation = $_GET['new_club'];
//Querys
    $qGetClub = "SELECT * FROM clubs WHERE validationID = '$validation'"; 
$rGetClub = mysql_query($qGetClub);
$Club = mysql_fetch_array($rGetClub);
//Query for category by name
$qGetCat = "SELECT * FROM club_category WHERE catID = ".$Club['cat']."";
$rGetCat = mysql_query($qGetCat);
$CatName = mysql_fetch_array($rGetCat);
//query for related sub categorys.
$qGetSub = "SELECT * FROM sub_categorys WHERE catID =".$Club['cat']."";
$rSubCat = mysql_query($qGetSub);
// query for groups created
$Groupq	=	mysql_query("SELECT * FROM groups WHERE memberID = '".$User['memberID']."'");

//end of querys

if(isset($_POST['insert_clubbtn1'])){ 
//Process data for validation     
$subcat    	= trim($_POST['subcat']);  
$NewSubCat = trim($_POST['NewSubCat']); 
//Prepare data for db insertion      
$subcat			= mysql_real_escape_string($subcat); 
//find the new category 
//insert
$result = mysql_query("UPDATE clubs  SET 
`sub_category`			=	'$subcat'
WHERE validationID ='$validation'") or die(mysql_error());



if ($result!=="") {		
$otherg	=	trim($_POST['other_groups']);
	$newg	=	trim($_POST['new_group']);
	$newg	=	mysql_real_escape_string($newg);     
	//if an item other than none from the list is selected then update the club with an ID relating to the group it belongs to			
if ($otherg !=='None') { $groupsq = mysql_query("UPDATE `clubs` SET groupID ='$otherg' WHERE validationID ='$validation'") or die (mysql_error()); }
// If none is selected then $newg must have a value so create a new group in the groups table and then on the next page I will add the group in the club table 		
else	{
$groupsq = mysql_query("INSERT INTO `groups` (`memberID`, `group`, `clubID`) VALUES ('".$User['memberID']."', '$newg', '".$Club['clubID']."')")or die (mysql_error());	
}   }

	if ($NewSubCat !="") { mail("mail","New Sub Category Request","Dear Ring Master,
\n\nThe club in the name of $name with a validation code of $validationID would like a new sub category called $new_cat\n\n  
\nTeam Arena\n\n\n\n"); }

$url = "/members/create/create_clubp3.php?new_club=$validation";  
header("Location: $url");     
}	

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.