Jump to content

not empty problem


zgkhoo

Recommended Posts

<?php
if(empty($row2[Downleft])||empty($row2[Downright]))//if downleft or downright is empty
{
echo "</br>Upline's down card still got space";
    	  								
if(empty($row2[Downleft])){
      echo "</br>save in downleft";
      mysql_query("UPDATE gamecard SET Downleft='{$row['Serialnum']}' WHERE Serialnum = 
     '$row2[serialnum]'") or die(mysql_error());
      mysql_query("UPDATE gamecard SET `Ownerid`= 
      '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or 
      die(mysql_error());
    	  									
}//end if
else{

      echo "</br>save in downright";

      mysql_query("UPDATE gamecard SET Downright='{$row['Serialnum']}' WHERE Serialnum =    
      '$row2[serialnum]'") or die(mysql_error());

      mysql_query("UPDATE gamecard SET `Ownerid`= 
      '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or 
      die(mysql_error());
}//end else
    	  								
if(!empty($row2[Downleft])){
     echo "</br>left not empty";
}
    	  								
if(!empty($row2[Downright])){
      echo "</br>right not empty";
}
    	  								
if(!empty($row2[Downleft])&&!empty($row2[Downright])){ //if both upline's downleft downright both not empty
      echo"</br>echo golden";
      mysql_query("UPDATE gamecard SET Golden='Valid' WHERE Serialnum = '$row2[serialnum]'") or die(mysql_error());
    	  							  	
    	  							  	
}//end if
?>

 

output:

Upline card's owner not null()

Upline's down card still got space

save in downleft

right not empty

 

 

 

since it got enter into and set the downleft..

 
<?php
if(empty($row2[Downleft])){
      echo "</br>save in downleft";
      mysql_query("UPDATE gamecard SET Downleft='{$row['Serialnum']}' WHERE Serialnum = 
     '$row2[serialnum]'") or die(mysql_error());
      mysql_query("UPDATE gamecard SET `Ownerid`= 
      '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or 
      die(mysql_error());
    	  									
}//end if
?>

but why still the program wont enter later on ?(after the above "if" set the downleft to a value and it not empty )

<?php
if(!empty($row2[Downleft])){
     echo "</br>left not empty";
}
?>

???? weird

 

 

 

Link to comment
Share on other sites

You are missing ' in a lot of places i think..

 

<?php

if(empty($row2['Downleft'])){
      echo "</br>save in downleft";
      mysql_query("UPDATE gamecard SET Downleft='{$row['Serialnum']}' WHERE Serialnum = 
     '$row2['Serialnum']'") or die(mysql_error());
      mysql_query("UPDATE gamecard SET `Ownerid`= 
      '$login',Upline='$row2['Serialnum']',Status='Registered' WHERE Serialnum = '$row['Serialnum']'") or 
      die(mysql_error());
    	  									
}//end if
?>

 

You should check the rest of the code

Link to comment
Share on other sites

Here is what I think, but I can be wrong

 

 

<---here i no add , also can working!..why?

you are testing of the variable exists/equals null/or has an empty value: "", 0

 

of course it will work.

$row2[Downleft] will always be empty as it is a non existing variable.

 

do a print_r($row2) to see what you have in that array.

This always helps me when I have some strange behaviour.

 

kind regards

anatak

Link to comment
Share on other sites

<?php
if(empty($row2['Downleft'])){
    	  									
   echo "</br>save in downleft";
   mysql_query("UPDATE gamecard SET Downleft='{$row['Serialnum']}' WHERE Serialnum = '$row2[serialnum]'") or die(mysql_error());
   mysql_query("UPDATE gamecard SET `Ownerid`= '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or die(mysql_error());
   echo "</br>after down left";
   print_r($row2);
    	  									
}//end if
?>

 

output:

after down leftArray ( [serialnum] => AAA0005 [serial] => 1005 [initial] => AAA [Activatecode] => FGQULZBE [Ownerid] => 1001 [status] => [Downleft] => [Downright] => AAA0011 [upline] => AAA0001 [Expireddate] => 2011-11-11 00:00:00 [Createdate] => 2011-11-11 00:00:00 [Point] => 100 [Golden] => Invalid )

 

weird, the row2[Downleft] is contain new data..it is not empty....why the print_r($row2) appear to null value? ??? ??? ??? ???  so weird

Link to comment
Share on other sites

the program seem store the downleft value into the DB only after whole program executed.

weird..

here is the whole program.


<?php
include '../../../config.php';
include '../../../opendb.php';

session_start();
$login=$_SESSION['UserID'];
$login=1009;
$foundcard=0;
$actcorrect=0;
$uplinefound=0;

    if(isset($_POST['button'])){
    	
    	   	$result=mysql_query("SELECT * from gamecard ORDER BY Serial");
    	   	
    	  	while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
    	  		//echo "</br>row serial=".$row[serialnum];
    	  		//echo "</br>row serial=".$_POST[serialnum];
    	  		
    	  		
    	  		if($row[serialnum]==$_POST[serialnum]){//if gamecard is found
    	  			echo "</br>match!!!";
    	  			$foundcard=1;
    	  		//	echo "</br>activate code=".$row[Activatecode];
    	  		 //   echo "</br>row serial=".$_POST[serialnum];
    	  		 if($row[status]!="Registered"){
    	  			
    	  			if($row[Activatecode]==$_POST[act]){
    	  				echo "</br>activate code correct!!!";
    	  				$actcorrect=1;
    	  				$result2=mysql_query("SELECT * from gamecard ORDER BY Serial");
    	  				while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC)){//finding match upline
    	  					if($row2[serialnum]==$_POST[upline]){//if upline card found
    	  						echo "</br>upline found!!!!!";
    	  						
    	  						$uplinefound=1;
    	  						echo "</br>before";
    	  						print_r($row2);
    	  						
    	  						if(!empty($row2[Ownerid])){//if Upline's Ownerid not null
    	  							echo "</br>Upline card's owner not null()";
    	  							if(empty($row2[Downleft])||empty($row2[Downright]))//if downleft or downright is empty
    	  							{
    	  								echo "</br>after";
    	  								print_r($row2);
    	  								echo "</br>Upline's down card still got space";
    	  								
    	  								if(empty($row2['Downleft'])){
    	  									
    	  									echo "</br>save in downleft";
    	  										mysql_query("UPDATE gamecard SET Downleft='$row[serialnum]' WHERE Serialnum = '$row2[serialnum]'") or die(mysql_error());
    	  										mysql_query("UPDATE gamecard SET `Ownerid`= '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or die(mysql_error());
    	  										echo "</br>after down left";
    	  										print_r($row2);
    	  									
    	  								}//end if
    	  								else{
    	  									echo "</br>save in downright";
    	  										mysql_query("UPDATE gamecard SET Downright='{$row['Serialnum']}' WHERE Serialnum = '$row2[serialnum]'") or die(mysql_error());
    	  										mysql_query("UPDATE gamecard SET `Ownerid`= '$login',Upline='$row2[serialnum]',Status='Registered' WHERE Serialnum = '$row[serialnum]'") or die(mysql_error());
    	  								}//end else
    	  								
    	  								if(!empty($row2['Downleft'])){
    	  									echo "</br>left not empty";
    	  								}
    	  								
    	  								if(!empty($row2['Downright'])){
    	  									echo "</br>right not empty";
    	  								}
    	  								
    	  							  if(!empty($row2[Downleft])&&!empty($row2[Downright])){ //if both upline's downleft downright both not empty
    	  							  	echo"</br>echo golden";
    	  							  	mysql_query("UPDATE gamecard SET Golden='Valid' WHERE Serialnum = '$row2[serialnum]'") or die(mysql_error());
    	  							  	
    	  							  	
    	  							  }//end if 
    	  							  else{
    	  							  	
    	  								
    	  							   }//end else
    	  							
    	  							
    	  						}//end if upline downline still got space
    	  						else{
    	  							echo "</br>upline card's down  still got space";
    	  						}//end else
    	  						
    	  						
    	  					}//end of opline owner id not null
    	  					else{
    	  						echo "</br>Sponsor Card not found";
    	  					}//end else
    	  					
    	  				}//end of if upline card found
    	  				echo "</br>after down all</br>";
    	  				print_r($row2);
    	  				
    	  			}//end end while finding the match upline card, row2
    	  			
    	  			
    	  			}//end if of activate code is correct
    	  			
    	  			else{
    	  				
    	  			}
    	  			
    	  			
    	  			
    	  		
    				}//end if 
    	  			else{
    	  				echo "</br>card is registered";
    	  			}
    	  			
    	  			

    	  			
    	  			   	  	
    	  		}//end outer if
    	  		else{
    	  		//	echo "</br>gamecard serial is invalid";
    	  		}

    	  			
    
    	  				
    	  	
    
    	  		
    	  	}//end while    	   	
    	   	
    }
    include '../../../closedb.php';
    

?>


<html>
<head>
<link rel="stylesheet" type="text/css" href="../../../style.css" />
</head> 
<form name='changepass' action='displayusraddc.php' method=post>
<table border="3">
<tr>
<td>
</td>
<td> 
<table border="3">
<tr>
<td>Card Serial</td>
<td><input type="text" name='serialnum' ></td>
</tr>
<tr>
<td>Card Activate Code</td>
<td><input type="text" name='act' ></td>
</tr>
<tr>
<td>Card's Sponsor Card's Serial</td>
<td><input type="text" name='upline'><td>
</tr>
<tr>
<td></td>
<td><input type="submit" name='button' value='comfirm'><td>
<tr>
</table>
</td>
</tr>
</table>
</form>
</html>



 

 

 

 

Link to comment
Share on other sites

wat is the different between $row2[Downleft] and $row2['Downleft']

 

The first is looking or an index that corisponds to the constant Downleft, the other the string 'Downleft'

 

Unless you have defined the constant Downleft somewhere your code is invalid. Turn on error reporting and you will see the warnings.

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.